default_content_format, ContentFormat::MARKDOWN); } catch (\Throwable) { // } return $schema ->components([ Select::make('category_id') ->label(__('admin.fields.category')) ->relationship('category', 'name') ->required(), Select::make('user_id') ->label(__('admin.fields.author')) ->relationship('user', 'name') ->required(), TextInput::make('title') ->label(__('admin.fields.title')) ->required() ->columnSpanFull(), Select::make('content_format') ->label(__('admin.fields.content_format')) ->options([ ContentFormat::MARKDOWN => __('admin.options.markdown_recommended'), ContentFormat::HTML => __('admin.options.html_legacy'), ]) ->default($defaultFormat) ->required() ->live() ->helperText(__('admin.helpers.article_content')), Textarea::make('content') ->label(fn (Get $get): string => $get('content_format') === ContentFormat::MARKDOWN ? __('admin.fields.content_markdown') : __('admin.fields.content_html')) ->required() ->rows(18) ->columnSpanFull(), TextInput::make('description') ->label(__('admin.fields.description')), TextInput::make('keywords') ->label(__('admin.fields.keywords')), TextInput::make('slug') ->label(__('admin.fields.slug')), DateTimePicker::make('published_at') ->label(__('admin.fields.published_at')) ->default(now()), Toggle::make('stick') ->label(__('admin.fields.stick')) ->default(false), Toggle::make('visible') ->label(__('admin.fields.visible')) ->default(true), Toggle::make('close_comment') ->label(__('admin.fields.close_comment')) ->default(false), TextInput::make('read_password') ->label(__('admin.fields.read_password')) ->password(), Textarea::make('ai_summary') ->label(__('admin.fields.ai_summary')) ->columnSpanFull(), ...Hook::collect('filament.article.form'), ]); } }