PHPackages                             sas-adilis/nova-nested-form - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sas-adilis/nova-nested-form

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sas-adilis/nova-nested-form
===========================

A Laravel Nova package that allows you to create/update/delete nested related fields from a parent form.

0353PHP

Since Sep 23Pushed 3y agoCompare

[ Source](https://github.com/sas-adilis/laravel-nova-nested-form)[ Packagist](https://packagist.org/packages/sas-adilis/nova-nested-form)[ RSS](/packages/sas-adilis-nova-nested-form/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/3a2d31fa904e9a061e3c754770e97bde0e7bd385bff8320152e86720db52ab3a/68747470733a2f2f706f7365722e707567782e6f72672f68616e646c65676c6f62616c2f6e6f76612d6e65737465642d666f726d2f762f737461626c65)](https://packagist.org/packages/handleglobal/nova-nested-form) [![Total Downloads](https://camo.githubusercontent.com/d7808d0d09f46f138f09faefc310b2fb1624da7bc27d7cb5bd6011746003bcc3/68747470733a2f2f706f7365722e707567782e6f72672f68616e646c65676c6f62616c2f6e6f76612d6e65737465642d666f726d2f646f776e6c6f616473)](https://packagist.org/packages/handleglobal/nova-nested-form) [![Latest Unstable Version](https://camo.githubusercontent.com/43ce608994a2f1bb7e52b288dbae10ebec83038c1c1e24149f790e48b1eddebb/68747470733a2f2f706f7365722e707567782e6f72672f68616e646c65676c6f62616c2f6e6f76612d6e65737465642d666f726d2f762f756e737461626c65)](https://packagist.org/packages/handleglobal/nova-nested-form) [![License](https://camo.githubusercontent.com/6559508748238a98321c97238cdabd251c6e899e49a07ad551d10c75ceaffbc6/68747470733a2f2f706f7365722e707567782e6f72672f68616e646c65676c6f62616c2f6e6f76612d6e65737465642d666f726d2f6c6963656e7365)](https://packagist.org/packages/handleglobal/nova-nested-form) [![Monthly Downloads](https://camo.githubusercontent.com/918c19352bf38dc8c02582b9fd6f8029ce5f2f165ad9aa1375a763691c58e72c/68747470733a2f2f706f7365722e707567782e6f72672f68616e646c65676c6f62616c2f6e6f76612d6e65737465642d666f726d2f642f6d6f6e74686c79)](https://packagist.org/packages/handleglobal/nova-nested-form) [![Daily Downloads](https://camo.githubusercontent.com/a0a3f382c581fc1634e156f3801c102dfe1d8e11ed40f50c1e698629fdd1b43b/68747470733a2f2f706f7365722e707567782e6f72672f68616e646c65676c6f62616c2f6e6f76612d6e65737465642d666f726d2f642f6461696c79)](https://packagist.org/packages/handleglobal/nova-nested-form)

Nova Nested Form
================

[](#nova-nested-form)

This package allows you to include your nested relationships' forms into a parent form.

Installation
============

[](#installation)

Add package to your composer with git reference

```
"repositories": [
        {
            "url": "https://github.com/handleglobal/laravel-nova-nested-form.git",
            "type": "git"
        }
]

```

```
composer require handleglobal/nova-nested-form:dev-master
```

Contributions
=============

[](#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!

Attach a new relationship form to a resource
============================================

[](#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.

```
namespace App\Nova;

use Laravel\Nova\Fields\ID;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Gravatar;
use Laravel\Nova\Fields\Password;
// Add use statement here.
use Handleglobal\NestedForm\NestedForm;

class User extends Resource
{
    ...
    public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),

            Gravatar::make(),

            Text::make('Name')
                ->sortable()
                ->rules('required', 'max:255'),

            Text::make('Email')
                ->sortable()
                ->rules('required', 'email', 'max:254')
                ->creationRules('unique:users,email')
                ->updateRules('unique:users,email,{{resourceId}}'),

            Password::make('Password')
                ->onlyOnForms()
                ->creationRules('required', 'string', 'min:6')
                ->updateRules('nullable', 'string', 'min:6'),

            // Add NestedForm here.
            NestedForm::make('Posts'),
        ];
    }
```

Choose when to display the form
===============================

[](#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:

```
class Post extends Resource
{
    ...
    public function fields(Request $request)
    {
        return [
            Boolean::make('Has Comments'),
            NestedForm::make('Comments')->displayIf(function ($nestedForm, $request) {
               return [
                    [ 'attribute' => 'has_comments', 'is' => true ]
               ];
        ];
    }
})
```

The **displayIf** method is excepted to return an array of array as you may want to add several conditions.

```
class Post extends Resource
{
    ...
    public function fields(Request $request)
    {
        return [
            Boolean::make('Has Comments'),
            Text::make('Title'),
            Text::make('Subtitle')->nullable(),
            Number::make('Number of comments allowed'),
            NestedForm::make('Comments')->displayIf(function ($nestedForm, $request) {
                return [
                    [ 'attribute' => 'has_comments', 'is' => true ],
                    [ 'attribute' => 'title', 'isNotNull' => true ],
                    [ 'attribute' => 'subtitle', 'isNull' => true ],
                    [ 'attribute' => 'title', 'includes' => 'My' ],
                    [ 'attribute' => 'number_of_comments_allowed', 'moreThanOrEqual' => 1 ],

                    // Integration for nova booleanGroup field
                    [ 'attribute' => 'my_multiple_checkbox', 'booleanGroup' => 'the_checkbox_key_to_target' ],
                ];
            })
        ];
    }
}
```

The package will then add those conditions and dynamically update your form as you fill the fields. The available rules are:

- is
- isNot
- isNull
- isNotNull
- isMoreThan
- isMoreThanOrEqual
- isLessThan
- isLessThanOrEqual
- includes
- booleanGroup

Add a minimum or a maximum number of children
=============================================

[](#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:

```
NestedForm::make('Posts')->min(3)->max(5),
```

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
======================================

[](#set-the-default-opencollapse-behavior)

If you want the nested forms to be opened by default, simply use:

```
NestedForm::make('Posts')->open(true),
```

Modify the default heading
==========================

[](#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.

```
NestedForm::make('Posts')->heading(NestedForm::wrapIndex() . ' // Post'),
```

You can also add any attribute of the current child into your heading using the helper method **wrapAttribute()**.

```
NestedForm::make('Posts')->heading(NestedForm::wrapIndex() . ' // ' . NestedForm::wrapAttribute('title', 'My default title')),
```

Modify the index separator
==========================

[](#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).

```
NestedForm::make('Posts')->separator('\'),

```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e42e96c5a2d8022e641c07befcdb87265ced5b87fc98a4a768efabd0570eb979?d=identicon)[adilis](/maintainers/adilis)

---

Top Contributors

[![yassilah](https://avatars.githubusercontent.com/u/13403295?v=4)](https://github.com/yassilah "yassilah (57 commits)")[![duckzland](https://avatars.githubusercontent.com/u/1064954?v=4)](https://github.com/duckzland "duckzland (14 commits)")[![buchkovsky](https://avatars.githubusercontent.com/u/12156092?v=4)](https://github.com/buchkovsky "buchkovsky (13 commits)")[![alberto-bottarini](https://avatars.githubusercontent.com/u/1442934?v=4)](https://github.com/alberto-bottarini "alberto-bottarini (11 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![arditqerosi](https://avatars.githubusercontent.com/u/65768218?v=4)](https://github.com/arditqerosi "arditqerosi (4 commits)")[![NoahNxT](https://avatars.githubusercontent.com/u/58152024?v=4)](https://github.com/NoahNxT "NoahNxT (4 commits)")[![303K](https://avatars.githubusercontent.com/u/3934941?v=4)](https://github.com/303K "303K (4 commits)")[![jangidgirish](https://avatars.githubusercontent.com/u/4018017?v=4)](https://github.com/jangidgirish "jangidgirish (4 commits)")[![andriiPalko](https://avatars.githubusercontent.com/u/21694348?v=4)](https://github.com/andriiPalko "andriiPalko (2 commits)")[![joseballester](https://avatars.githubusercontent.com/u/12814091?v=4)](https://github.com/joseballester "joseballester (2 commits)")[![zippoxer](https://avatars.githubusercontent.com/u/859015?v=4)](https://github.com/zippoxer "zippoxer (1 commits)")[![atmonshi](https://avatars.githubusercontent.com/u/1952412?v=4)](https://github.com/atmonshi "atmonshi (1 commits)")[![gazben](https://avatars.githubusercontent.com/u/3780285?v=4)](https://github.com/gazben "gazben (1 commits)")[![jeffreydevreede](https://avatars.githubusercontent.com/u/2203546?v=4)](https://github.com/jeffreydevreede "jeffreydevreede (1 commits)")[![MaxKorlaar](https://avatars.githubusercontent.com/u/8917249?v=4)](https://github.com/MaxKorlaar "MaxKorlaar (1 commits)")[![pindab0ter](https://avatars.githubusercontent.com/u/5128166?v=4)](https://github.com/pindab0ter "pindab0ter (1 commits)")[![sas-adilis](https://avatars.githubusercontent.com/u/299831?v=4)](https://github.com/sas-adilis "sas-adilis (1 commits)")[![ThibaudDauce](https://avatars.githubusercontent.com/u/1770543?v=4)](https://github.com/ThibaudDauce "ThibaudDauce (1 commits)")[![tomheno](https://avatars.githubusercontent.com/u/30948041?v=4)](https://github.com/tomheno "tomheno (1 commits)")

### Embed Badge

![Health badge](/badges/sas-adilis-nova-nested-form/health.svg)

```
[![Health](https://phpackages.com/badges/sas-adilis-nova-nested-form/health.svg)](https://phpackages.com/packages/sas-adilis-nova-nested-form)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
