Download the PHP package formfeed-uk/nova-dependable-panel without Composer
On this page you can find all versions of the php package formfeed-uk/nova-dependable-panel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download formfeed-uk/nova-dependable-panel
More information about formfeed-uk/nova-dependable-panel
Files in formfeed-uk/nova-dependable-panel
Package nova-dependable-panel
Short Description A Laravel Nova Field acting as a Panel for grouped dependsOn functionality
License MIT
Informations about the package nova-dependable-panel
Nova 4 Dependable Panel
This Laravel Nova package adds Panels that allow grouped dependsOn functionality
Dusk Test Repo: https://github.com/Formfeed-UK/nova-dependable-panel-tests
Requirements
php: ^7.3|^8.0
laravel/nova: ^4.0
Features
- Grouping all dependsOn requests for fields within this panel into one request
- Hiding/Showing the entire Panel based on a dependsOn function
- Changing the Fields within the Panel as a result of a dependsOn function
- Making a batched dependsOn function for all fields within the panel, (overidden at the Field Level)
- Works with Nova Tabs
- Works with the fork of Nova Flexible Content allowing for dependsOn fields within Layout Groups
- Fields can be added to an existing panel or seperated into a new one
Note that this package is an extension of a Field, rather than a Panel, however it can act as a panel when the separatePanel
method is used. This is to allow more flexibility to use fields as part of an existing Panel.
Installation
Install the package in to a Laravel app that uses Nova via composer:
Usage
Basic Usage
Hiding the entire Panel based on a dependsOn function
Single dependsOn request for all fields within the panel
All of the Text Fields dependsOn requests will be sent as one request using the singleRequest
method. This is useful for both reducing the number of requests on large forms and for more consistent UX as the fields are changed at the same time.
Batching dependsOn functionality for all contained fields
You can also batch dependsOn functionality for all fields within your Panel using the applyToFields
method. For example if you need all fields to become readOnly. This can be overidden at the Field Level.
Note that the first parameter should be of type Field
to ensure that the function can apply to all fields within your panel, regardless of type.
Separating the Panel
The fields in Nova Dependable Panel can be part of any other panel (default), or can be separated into another panel using the separatePanel
method.
This panel will use the first argument to DependablePanel as its panel name.
Changing the fields in the Panel as a result of dependsOn
Rather than hiding/showing fields as a result of dependsOn, you can change the fields themselves using the fields
method. Note that this functionality requires singleRequest
to operate properly.
Note: If the fields added via the fields
method also have dependsOn defined, and you wish those dependsOn mixins to be applied correctly when those fields are first mounted, you should include the fields that they depend upon in the panels dependsOn
function.
In the example below if the "Readonly" checkbox is checked, and then the select option is changed to Option 1, in order for these fields to be readonly when mounted, you can see "readonly" needs to be included in the panels dependsOn
function.
Known Issues
- Panels cannot be seperated/combined in the dependsOn function, this can only be set once upon page load
- When swapping between different sets of fields via the
Fields
method in the PanelsdependsOn
changed values will not persist on the update form for fields where values are already stored in the database for that resource. - Nova's Boolean field doesn't behave as expected due to its value being set to false when it is null, this means that Boolean fields altered by the dependable panel will be false, which isn't great UX. A middleware fix is incoming, but for now it's recommended to extend the Boolean field within your project and perform the following override:
License
Nova Dependable Panel is open-sourced software licensed under the MIT license.
All versions of nova-dependable-panel with dependencies
laravel/nova Version ^4.0
nova-kit/nova-packages-tool Version ^1.0
formfeed-uk/nova-subfield-dependson Version ^2.0.0