{"id":13563478,"url":"https://github.com/yassilah/laravel-nova-nested-form","last_synced_at":"2025-05-16T06:04:32.569Z","repository":{"id":42472016,"uuid":"154369161","full_name":"yassilah/laravel-nova-nested-form","owner":"yassilah","description":"This package allows you to include your nested relationships' forms into a parent form.","archived":false,"fork":false,"pushed_at":"2024-05-13T14:37:48.000Z","size":2233,"stargazers_count":240,"open_issues_count":60,"forks_count":96,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-16T06:04:11.612Z","etag":null,"topics":["children","form","laravel","nested","nova","relationships","tool"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yassilah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-10-23T17:26:13.000Z","updated_at":"2024-09-08T21:29:19.000Z","dependencies_parsed_at":"2024-01-14T03:46:48.314Z","dependency_job_id":"73ee6552-c18d-46e3-9c16-bc8a0037e5db","html_url":"https://github.com/yassilah/laravel-nova-nested-form","commit_stats":{"total_commits":141,"total_committers":25,"mean_commits":5.64,"dds":0.5957446808510638,"last_synced_commit":"f1fa36a2d359d75a334cc3f7596dbd2f5de2e83e"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yassilah%2Flaravel-nova-nested-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yassilah%2Flaravel-nova-nested-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yassilah%2Flaravel-nova-nested-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yassilah%2Flaravel-nova-nested-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yassilah","download_url":"https://codeload.github.com/yassilah/laravel-nova-nested-form/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478186,"owners_count":22077675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["children","form","laravel","nested","nova","relationships","tool"],"created_at":"2024-08-01T13:01:19.729Z","updated_at":"2025-05-16T06:04:32.514Z","avatar_url":"https://github.com/yassilah.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/yassi/nova-nested-form/v/stable)](https://packagist.org/packages/yassi/nova-nested-form) [![Total Downloads](https://poser.pugx.org/yassi/nova-nested-form/downloads)](https://packagist.org/packages/yassi/nova-nested-form) [![Latest Unstable Version](https://poser.pugx.org/yassi/nova-nested-form/v/unstable)](https://packagist.org/packages/yassi/nova-nested-form) [![License](https://poser.pugx.org/yassi/nova-nested-form/license)](https://packagist.org/packages/yassi/nova-nested-form) [![Monthly Downloads](https://poser.pugx.org/yassi/nova-nested-form/d/monthly)](https://packagist.org/packages/yassi/nova-nested-form) [![Daily Downloads](https://poser.pugx.org/yassi/nova-nested-form/d/daily)](https://packagist.org/packages/yassi/nova-nested-form)\n\n# Nova Nested Form\n\nThis package allows you to include your nested relationships' forms into a parent form.\n\n# Installation\n\n```bash\ncomposer require yassi/nova-nested-form\n```\n\n# Contributions\n\nAs 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!  \n\n# Update to 3.0\n\nThe **afterFill** and **beforeFill** methods are no longer available.\n\n# Attach a new relationship form to a resource\n\nSimply 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.\n\n```php\nnamespace App\\Nova;\n\nuse Laravel\\Nova\\Fields\\ID;\nuse Illuminate\\Http\\Request;\nuse Laravel\\Nova\\Fields\\Text;\nuse Laravel\\Nova\\Fields\\Gravatar;\nuse Laravel\\Nova\\Fields\\Password;\n// Add use statement here.\nuse Yassi\\NestedForm\\NestedForm;\n\nclass User extends Resource\n{\n    ...\n    public function fields(Request $request)\n    {\n        return [\n            ID::make()-\u003esortable(),\n\n            Gravatar::make(),\n\n            Text::make('Name')\n                -\u003esortable()\n                -\u003erules('required', 'max:255'),\n\n            Text::make('Email')\n                -\u003esortable()\n                -\u003erules('required', 'email', 'max:254')\n                -\u003ecreationRules('unique:users,email')\n                -\u003eupdateRules('unique:users,email,{{resourceId}}'),\n\n            Password::make('Password')\n                -\u003eonlyOnForms()\n                -\u003ecreationRules('required', 'string', 'min:6')\n                -\u003eupdateRules('nullable', 'string', 'min:6'),\n\n            // Add NestedForm here.\n            NestedForm::make('Posts'),\n        ];\n    }\n```\n\n# Choose when to display the form\n\nFor instance, if the nested form should only be available if the value of the \"has_comments\" attirbute is true, you can use:\n\n```php\nclass Post extends Resource\n{\n    ...\n    public function fields(Request $request)\n    {\n        return [\n            Boolean::make('Has Comments'),\n            NestedForm::make('Comments')-\u003edisplayIf(function ($nestedForm, $request) {\n               return [\n                    [ 'attribute' =\u003e 'has_comments', 'is' =\u003e true ]\n               ];\n        ];\n    }\n})\n```\n\nThe **displayIf** method is excepted to return an array of array as you may want to add several conditions.\n\n```php\nclass Post extends Resource\n{\n    ...\n    public function fields(Request $request)\n    {\n        return [\n            Boolean::make('Has Comments'),\n            Text::make('Title'),\n            Text::make('Subtitle')-\u003enullable(),\n            Number::make('Number of comments allowed'),\n            NestedForm::make('Comments')-\u003edisplayIf(function ($nestedForm, $request) {\n                return [\n                    [ 'attribute' =\u003e 'has_comments', 'is' =\u003e true ],\n                    [ 'attribute' =\u003e 'title', 'isNotNull' =\u003e true ],\n                    [ 'attribute' =\u003e 'subtitle', 'isNull' =\u003e true ],\n                    [ 'attribute' =\u003e 'title', 'includes' =\u003e 'My' ],\n                    [ 'attribute' =\u003e 'number_of_comments_allowed', 'moreThanOrEqual' =\u003e 1 ],\n\n                    // Integration for nova booleanGroup field\n                    [ 'attribute' =\u003e 'my_multiple_checkbox', 'booleanGroup' =\u003e 'the_checkbox_key_to_target' ],\n                ];\n            })\n        ];\n    }\n}\n```\n\nThe package will then add those conditions and dynamically update your form as you fill the fields. The available rules are:\n\n- [x] is\n- [x] isNot\n- [x] isNull\n- [x] isNotNull\n- [x] isMoreThan\n- [x] isMoreThanOrEqual\n- [x] isLessThan\n- [x] isLessThanOrEqual\n- [x] includes\n- [x] booleanGroup\n\n# Add a minimum or a maximum number of children\n\nFor instance, if you want every user to have at least 3 posts and at most 5 posts, simply use:\n\n```php\nNestedForm::make('Posts')-\u003emin(3)-\u003emax(5),\n```\n\nPlease note that the package automatically detects whether the relationship excepts many children or a single child, and sets the maximum value accordingly.\n\nWhen 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.\n\n# Set the default open/collapse behavior\n\nIf you want the nested forms to be opened by default, simply use:\n\n```php\nNestedForm::make('Posts')-\u003eopen(true),\n```\n\n# Modify the default heading\n\nYou 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.\n\n```php\nNestedForm::make('Posts')-\u003eheading(NestedForm::wrapIndex() . ' // Post'),\n```\n\nYou can also add any attribute of the current child into your heading using the helper method **wrapAttribute()**.\n\n```php\nNestedForm::make('Posts')-\u003eheading(NestedForm::wrapIndex() . ' // ' . NestedForm::wrapAttribute('title', 'My default title')),\n```\n\n# Modify the index separator\n\nYou 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).\n\n```php\nNestedForm::make('Posts')-\u003eseparator('\\'),\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyassilah%2Flaravel-nova-nested-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyassilah%2Flaravel-nova-nested-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyassilah%2Flaravel-nova-nested-form/lists"}