Download the PHP package yassi/nova-nested-form without Composer
On this page you can find all versions of the php package yassi/nova-nested-form. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package nova-nested-form
Nova Nested Form
This package allows you to include your nested relationships' forms into a parent form.
Installation
Contributions
As I did not anticipate so many people would use that package (which is awesome) and simply do not have enough time to update/enhance this package more regularly on my own, I am looking for other contributors to help me with the maintenance and feature requests. Don't hesitate to contact me if you're interested!
Update to 3.0
The afterFill and beforeFill methods are no longer available.
Attach a new relationship form to a resource
Simply add a NestedForm into your fields. The first parameter must be an existing NovaResource class and the second parameter (optional) must be an existing HasOneOrMany relationship in your model.
Choose when to display the form
For instance, if the nested form should only be available if the value of the "has_comments" attirbute is true, you can use:
The displayIf method is excepted to return an array of array as you may want to add several conditions.
The package will then add those conditions and dynamically update your form as you fill the fields. The available rules are:
- [x] is
- [x] isNot
- [x] isNull
- [x] isNotNull
- [x] isMoreThan
- [x] isMoreThanOrEqual
- [x] isLessThan
- [x] isLessThanOrEqual
- [x] includes
- [x] booleanGroup
Add a minimum or a maximum number of children
For instance, if you want every user to have at least 3 posts and at most 5 posts, simply use:
Please note that the package automatically detects whether the relationship excepts many children or a single child, and sets the maximum value accordingly.
When creating a new user, 3 blank posts will be displayed. If you reach the maximum number of posts, the "Add a new post" button will disappear.
Set the default open/collapse behavior
If you want the nested forms to be opened by default, simply use:
Modify the default heading
You can modify the default heading using the heading() method. You can use the helper method wrapIndex() to add the current child index to your header.
You can also add any attribute of the current child into your heading using the helper method wrapAttribute().
Modify the index separator
You can modify the default index separator using the separator() method when you have nested forms (e.g. 1. Post, 1.1. Comment, 1.1.1. Like).