lupennat / items
Laravel Nova - Items Field
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:Vue
Requires
- php: ^7.4|^8.0
- laravel/nova: ^4.12
- nova-kit/nova-packages-tool: ^1.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.16
README
Requirements
php: ^7.4 | ^8
laravel/nova: ^4
Installation
composer require lupennat/items
Usage
Laravel Nova array items field with sorting, validation & many display options
use Lupennat\Items\Items;
function fields() { return [ Items::make('Emails'), ] }
and be sure to cast the property as an array on your eloquent model
public $casts = [ 'emails' => 'array' ];
Validation
Use Laravel's built in array validation
Items::make('Emails')->rules([ 'emails.*' => 'email|min:10', ]),
Manually setting the attribute may be needed in some cases.
Items::make('Long Text', 'attribute')->rules([ 'attribute.*' => 'email|min:10', ]),
Additional options
function | description | default |
---|---|---|
->max(number) |
limit number of items allowed | false |
->draggable() |
turn on drag/drop sorting | false |
->onlyDraggable() |
turn on drag/drop sorting and off add,delete,editing | false |
->inputType(text) |
text, date, etc (support "select") | "text" |
->placeholder($value) |
the new item input text | "Add a new item" |
->actionText($value) |
value for create button | "Add" |
->disableAddingRows() |
hide the "add" button | false |
->disableDeletingRows() |
hide the "delete" button | false |
->disableEditingRows() |
input on readonly mode | false |
->displayAsList() |
display list on index as list instead of comma separated values | "group" |
Credits
Items field is based on Nova Items Field.