Download the PHP package lupennat/nested-form without Composer
On this page you can find all versions of the php package lupennat/nested-form. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package nested-form
this repository will no longer have updates, a new version of the package is available here
- Requirements
- Installation
- Usage
- DependsOn
- Additional options
- Prefill
- Custom Heading
- Credits
Requirements
php: ^7.4 | ^8
laravel/nova: ^4
Installation
Usage
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.
NestedForm is visible by deafult on DetailPage, UpdatePage and CreatePage. NestedForm is not available on IndexPage.
Depends On
NestedForm support Nova dependsOn
.
it also support a short version of dependsOn without callback
Both syntax will propagate the condition to related resource, you can access propagated content adding HasNestedForm
trait on your related resource.
Additional options
function | description | default |
---|---|---|
->max(int) |
limit number of related resources allowed | 0 |
->min(int) |
minimum number of related resources | 0 |
->lock() |
disable add and remove related resources | false |
->prefill(array,bool) |
prefill related resources with values | [], false |
->useTabs() |
switch display mode to tabs instead of panels | false |
->activeTab(int) |
set default active tab by index | 0 |
->activeTabByHeading(string) |
set default active tab by 'heading' | null |
->canDuplicate() |
enable duplicate resource button | false |
->canRestore() |
enable soft delete on resource when deleted (only vue) | false |
->addText(string) |
text for add button | "add $resourceName" |
->restoreText(string) |
text for restore button | "restore $resourceName" |
->removeText(string) |
text for remove button | "remove $resourceName" |
->duplicateText(string) |
text for duplicate button | "duplicate $resourceName" |
->heading(string, boolean) |
define custom heading | [], false |
->separator(string) |
define heading separator | " . " |
Prefill
You can use prefill
method to generate a default set of related resource.
Prefill works only on Create Page
You can force prefill to always respect the numbers of prefilled items through a second boolean parameter.
Custom Heading
By Default NestedForm Heading is:
- DetailPage
${resourceName} ${keyName}: ${resource[keyName]}
- UpdatePage exists
${resourceName} ${keyName}: ${resource[keyName]}
new${index} ${separator} ${resourceName}
- CreatePage
${index} ${separator} ${resourceName}
You can specify a Custom Heading using resource fields value, defining attribute names, through heading
method, the second parameter of the method specify if the heading should be "unique".
When a custom heading is defined, the fields are hidden on the panel, but when the user try to add a new resource a modal with required fields is displayed; if unique is true, NestedForm will check to existing related resource the uniqueness of the fields. Multiple fields value will be concatened by the defined separator.
Credits
NestedForm field is based on original Nova Nested Form.