https://github.com/dillingham/nova-conditional-fields
WIP: Conditionally display fields based on another field's value
https://github.com/dillingham/nova-conditional-fields
laravel laravel-nova
Last synced: 10 months ago
JSON representation
WIP: Conditionally display fields based on another field's value
- Host: GitHub
- URL: https://github.com/dillingham/nova-conditional-fields
- Owner: dillingham
- License: mit
- Created: 2019-02-08T01:36:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-29T02:28:06.000Z (over 5 years ago)
- Last Synced: 2025-05-07T14:52:48.397Z (about 1 year ago)
- Topics: laravel, laravel-nova
- Language: PHP
- Homepage:
- Size: 106 KB
- Stars: 39
- Watchers: 2
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Nova Conditional Fields
[](https://packagist.org/packages/dillingham/nova-conditional-fields)
[](https://packagist.org/packages/dillingham/nova-conditional-fields) [](https://twitter.com/im_brian_d)
Conditionally display fields based on another field's value
### Install
```
composer require dillingham/nova-conditional-fields
```
### Usage
```php
use NovaConditionalFields\Condition;
```
Example using a boolean field
```php
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
```php
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](https://novapackages.com/collaborators/dillingham)
Hope you find it useful. Feel free to reach out with feedback.
Follow me on twitter: [@im_brian_d](https://twitter.com/im_brian_d)