lupennat/items

This package is abandoned and no longer maintained. No replacement package was suggested.

Laravel Nova - Items Field

Installs: 19

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Language:Vue

v1.1.1 2023-05-24 12:27 UTC

This package is auto-updated.

Last update: 2023-12-12 11:38:21 UTC


README

  1. Requirements
  2. Installation
  3. Usage
  4. Validation
  5. Additional options
  6. Credits

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.