/nova-conditional-fields

WIP: Conditionally display fields based on another field's value

Primary LanguagePHPMIT LicenseMIT

Nova Conditional Fields

Latest Version on Github Total Downloads Twitter Follow

Conditionally display fields based on another field's value

Install

composer require dillingham/nova-conditional-fields

Usage

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'),
    ])

Coming soon

-- BelongsTo support

-- whenTrue

-- whenNot

-- whenEmpty


Author

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