LaravelPackages.net
Acme Inc.
Toggle sidebar
hosnyben/nova-nested-inputs

Nova Nested Fields is a Laravel Nova field package that allows users to present their checkboxes or radio buttons in a nested, hierarchical structure. This package supports infinite nesting levels, providing a flexible solution for complex form requirements.

504
8
1.0.0
About hosnyben/nova-nested-inputs

hosnyben/nova-nested-inputs is a Laravel package for nova nested fields is a laravel nova field package that allows users to present their checkboxes or radio buttons in a nested, hierarchical structure. this package supports infinite nesting levels, providing a flexible solution for complex form requirements.. It currently has 8 GitHub stars and 504 downloads on Packagist (latest version 1.0.0). Install it with composer require hosnyben/nova-nested-inputs. Discover more Laravel packages by hosnyben or browse all Laravel packages to compare alternatives.

Last updated

Nova Nested Inputs

Nova Nested Fields is a Laravel Nova field package that allows users to present their checkboxes or radio buttons in a nested, hierarchical structure. This package supports infinite nesting levels, providing a flexible solution for complex form requirements.

Requirements

  • php: >=7.3
  • laravel/nova: ^4.26

Demo

Nested radios input

Nested radio input

Nested checkbox input

Nested checkbox input

Features

  • Infinite nesting of checkbox/radio fields.
  • Easy integration with existing Laravel Nova projects.
  • Customizable display and styling options.
  • Supports dynamic addition and removal of nested items.
  • Intuitive user interface for managing nested selections.

Installation

To install the Nova Nested Fields package, use Composer:

# Install Nova Nested Inputs
composer require hosnyben/nova-nested-inputs

Usage

Now you can use the NovaNestedInputs Field with Nova. Make the NovaNestedInputs in the fields method like any other field in a Resource.

Example
// in a Nova Resource

use HosnyBEN\NovaNestedInputs\NovaNestedInputs;

public function fields(Request $request)
{
    return [
            NovaNestedInputs::make('Category', 'category_id')
                ->options(function() {
                    return [
                        ['id' => 1, 'label' => 'Parent 1'],
                        ['id' => 2, 'label' => 'Parent 2'],
                        ['id' => 3, 'label' => 'Parent 3'],
                        [
                            'id' => 4,
                            'label' => 'Parent 4',
                            'children' => [
                                ['id' => 5, 'label' => 'Child 4.1'],
                                [
                                    'id' => 6, 
                                    'label' => 'Child 4.2',
                                    'children' => [
                                        ['id' => 8, 'label' => 'Child 4.2.1'],
                                        ['id' => 9, 'label' => 'Child 4.2.2'],
                                    ],
                                ],
                                ['id' => 7, 'label' => 'Child 4.3'],
                            ],
                        ],
                    ];
                })
                ->type('radio')
                ->color('#be860f')
                ->rules('required'),
    ]
}

Settings

| Option | Type | Description | Default | | :------------ | :------------ | :------------ | :------------ | | type | String | You define either a checkbox or radio | radio | | color | String | You define the CSS supported color. It may be a hex color or rgb() or rgba() | #be860f | | options | function() or multi-dimensional Array[]. It must respect the payload. | You can define infinte loop of nested items. You may use a function if you're looking to load dynamic values of load your Eloquent model into. | array() |

"options" field structure
[
	[
		'id' => 1, // ID of the record
		'label' => 'My item', // String : Title of the item
		'disabled' => false, // Boolean
		'children' => [ // Array of nested item with the exact structure
			...
		]
    	],
    	...
]

License

Nova Nested Inputs is open-sourced software licensed under the MIT license.

Author

Hosny BEN

Made with ❤️ by Hosny BEN

Comments