Conditionally display fields based on another field's value
composer require dillingham/nova-conditional-fields
use NovaConditionalFields\Condition;
Example using a boolean field
Boolean::make('Show Fields'),
Condition::make('Show Fields')
->when(true, [
Text::make('Extra Setting 1'),
Text::make('Extra Setting 2'),
Text::make('Extra Setting 3'),
])
An example using select
Select::make('Type')->options([
'type-1' => 'Type 1',
'type-2' => 'Type 2',
]),
Condition::make('Type')
->fieldsWhen('type-1', [
Text::make('Setting 1'),
Text::make('Setting 2'),
Text::make('Setting 3'),
])->when('type-2', [
Text::make('Setting 4'),
Text::make('Setting 5'),
Text::make('Setting 6'),
])
-- BelongsTo support
-- whenTrue
-- whenNot
-- whenEmpty
Hi 👋, Im Brian Dillingham, creator of this Nova package and others
Hope you find it useful. Feel free to reach out with feedback.
Follow me on twitter: @im_brian_d