<?php
class FormExample extends Page implements HasForms
{
use InteractsWithForms;
use HasHelperText;
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.form';
public ?array $data = [];
public function mount(): void
{
$this->form->fill();
}
public function form(Form $form): Form
{
return $form
->schema([
Section::make('Publishing')
->description('Settings for publishing this post.')
->schema([
Select::make('status')
->options([
'draft' => 'Draft',
'reviewing' => 'Reviewing',
'published' => 'Published',
])
->live()
->helperText(fn(Get $get) => match ($get('status')) {
'draft', 'reviewing'
=> str('This post **will not be visible** to the public until it is published.')
->inlineMarkdown()->toHtmlString(),
'published'
=> str('This post **is visible** to the public.')->inlineMarkdown()->toHtmlString(),
default => '',
})->live(),
DateTimePicker::make('published_at')
->hidden(fn(Get $get) => $get('status') !== 'published'),
]),
]);
}
}
<?php
class FormExample extends Page implements HasForms
{
use InteractsWithForms;
use HasHelperText;
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.form';
public ?array $data = [];
public function mount(): void
{
$this->form->fill();
}
public function form(Form $form): Form
{
return $form
->schema([
Section::make('Publishing')
->description('Settings for publishing this post.')
->schema([
Select::make('status')
->options([
'draft' => 'Draft',
'reviewing' => 'Reviewing',
'published' => 'Published',
])
->live()
->helperText(fn(Get $get) => match ($get('status')) {
'draft', 'reviewing'
=> str('This post **will not be visible** to the public until it is published.')
->inlineMarkdown()->toHtmlString(),
'published'
=> str('This post **is visible** to the public.')->inlineMarkdown()->toHtmlString(),
default => '',
})->live(),
DateTimePicker::make('published_at')
->hidden(fn(Get $get) => $get('status') !== 'published'),
]),
]);
}
}