New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

nurmuhammet/dynamic-fields

Dynamic fields for laravel nova.
4,601 2
Install
composer require nurmuhammet/dynamic-fields
Latest Version:1.1.0
PHP:^7.3|^8.0
Laravel:8 · 9 · 10
License:MIT
Last Updated:Dec 27, 2023
Links: GitHub  ·  Packagist
Maintainer: nurmuhammet

Nova Dynamic fields

Dynamic fields for nova. Will fill resource attributes with given name. Can be very useful even for the many to many relationships. Supports dependent fields.

Requirements

  • php: >=8.0
  • laravel/nova: ^4.0

Installation

Install the package in a Laravel Nova project via Composer:

# Install nova-inputmask
composer require nurmuhammet/dynamic-fields

Usage

use Nurmuhammet\DynamicFields\DynamicFields;

// ...
DynamicFields::make('Attributes', 'attributes')
    ->fields([
        ['type' => 'text', 'name' => 'Brand', 'label' => 'Label', 'required' => true, 'placeholder' => 'Adidas...', 'default' => 'default value'],
        ['type' => 'number', 'name' => 'B'],
        ['type' => 'select', 'name' => 'Colour', 'label' => 'Colour of product', 'options' => [
            ['label' => 'A', 'value' => 10],
            ['label' => 'B', 'value' => 19]
        ]]
    ])
    
    ->fillWithArrayName('names') // if you want form name should be array, like: `names[]`

fields(array|callable $fields)

If closure is passed, the array have to be returned by closure
Attribute type required default
name string yes
type string, valid input types: text, number, select yes
label string, integer... no name will be capitalized
default string, integer... no null
options array, returned array must have label & value keys, example: [['label' => 'Field label', 'value' => 'field value'], ...] no null
required bool no false
placeholder string, integer... no ''

fillWithArrayName(string $requestArrayName = '')

Fills all fields with names & values into one array

If you find my open-source library helpful, consider supporting it by buying me a coffee: Buy Me a Coffee. ☕

Related Packages

epartment/nova-dependency-container

A Laravel Nova field container allowing to depend on other fields values

4,693,752 378
eminiarts/nova-tabs

Laravel Nova - Tabs.

4,610,439 464
ebess/advanced-nova-media-library

Laravel Nova tools for managing the Spatie media library.

3,857,876 616
spatie/nova-tags-field

A tags field for Nova apps

2,337,323 301
kabbouchi/nova-impersonate

A Laravel Nova field allows you to authenticate as your users.

2,268,645 234

Version History

Version Released PHP Laravel License
1.1.0 ^7.3|^8.0 ^8.0|^9.0|^10.0 MIT
1.0.1 ^7.3|^8.0 ^8.0|^9.0|^10.0 MIT
1.0.0 ^7.3|^8.0 ^8.0|^9.0 MIT