Skip to content

Commit

Permalink
Added 3rd party support
Browse files Browse the repository at this point in the history
 - Added better component scanning in order to set up the correct field watchers
 - Added a dependsOnCustomComponent method that allows 3rd party field dependencies
  • Loading branch information
Jeroen Nijhuis committed Sep 13, 2018
1 parent 6124b7b commit bf932c1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 10,535 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ You can use any type of field type dependency, i.e. a checkbox:
])->dependsOn('active', true)->onlyOnForms(),
```

### 3rd Party support
Using the `dependsOnCustomComponent` method on the Dependency Container, you can target 3rd Party Nova Components. Specifying the exact component name , the Dependency Container will add value watchers to these components, allowing you to depend on their values. You can find the component names `field.js` file in the source of the 3rd party package. Usually they start with `form-{component-name}`.

For example using the https://github.com/davidpiesse/nova-toggle field, you can get the name of the component here: https://github.com/davidpiesse/nova-toggle/blob/master/resources/js/field.js#L7 and use it like below:

```php
\Davidpiesse\NovaToggle\Toggle::make('Our Option', 'selectable_option')->hideFromIndex(),

\Epartment\NovaDependencyContainer\NovaDependencyContainer::make('Dependent settings', [
\Laravel\Nova\Fields\Trix::make('Details', 'selectable_option_details'),
])->dependsOn('selectable_option', true)->dependsOnCustomComponent('form-nova-toggle'),
```


### Data handling
The container it self won't contain any values and will simply pass through the values of the contained fields and their corresponding attributes.

### License
Expand Down
Loading

0 comments on commit bf932c1

Please sign in to comment.