public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('test'),
Forms\Components\TextInput::make('title')
->required()
->maxLength(255)
->live(onBlur: true)
->afterStateUpdated(function (Forms\Get $get, Forms\Set $set, ?string $old, ?string $state) {
if (($get('slug') ?? '') !== Str::slug($old)) {
return;
}
$set('slug', Str::slug($state));
}),
Forms\Components\TextInput::make('slug')
->required()
->maxLength(255),
Forms\Components\Builder::make('data')
->blocks([
Builder\Block::make('heading')
->schema([
Components\TextInput::make('content')
->label('Heading')
->required(),
Components\Select::make('level')
->options([
'h1' => 'Heading 1',
'h2' => 'Heading 2',
'h3' => 'Heading 3',
'h4' => 'Heading 4',
'h5' => 'Heading 5',
'h6' => 'Heading 6',
])
->required()
])
->columns(2);
])
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('test'),
Forms\Components\TextInput::make('title')
->required()
->maxLength(255)
->live(onBlur: true)
->afterStateUpdated(function (Forms\Get $get, Forms\Set $set, ?string $old, ?string $state) {
if (($get('slug') ?? '') !== Str::slug($old)) {
return;
}
$set('slug', Str::slug($state));
}),
Forms\Components\TextInput::make('slug')
->required()
->maxLength(255),
Forms\Components\Builder::make('data')
->blocks([
Builder\Block::make('heading')
->schema([
Components\TextInput::make('content')
->label('Heading')
->required(),
Components\Select::make('level')
->options([
'h1' => 'Heading 1',
'h2' => 'Heading 2',
'h3' => 'Heading 3',
'h4' => 'Heading 4',
'h5' => 'Heading 5',
'h6' => 'Heading 6',
])
->required()
])
->columns(2);
])
]);
}