Skip to content
tanthammar edited this page Sep 4, 2020 · 1 revision

Array Field Declaration (Repeater)

ArrayFields are slightly different than Fields. They should only be declared within the field array() method. They have most of the same methods available, except for file(), array() or keyval(). They also have a colspan() method unavailable to Fields.

make($name)

$name

The name to use for the array field, e.g. phone_number. Array fields do not use labels. Rather, you should specify a placeholder() for them instead.

Example:

ArrayField::make('phone_number')->input('tel')->placeholder('Phone Number')->rules('required'),

array($fields = [])

Sets the field to be an array of fields.

$fields

An array of ArrayFields to use.

Example:

    Field::make('Owners')->array([
        ArrayField::make('Full Name')->input()->placeholder('Full Name')->rules('required'),
        ArrayField::make('Phone Number')->input('tel')->placeholder('Phone Number'),
    ]),

Use the sortable() method on the ArrayField to make the array fields sortable:

    Field::make('Owners')->array([
        ArrayField::make('Full Name')->input()->placeholder('Full Name')->rules('required'),
        ArrayField::make('Phone Number')->input('tel')->placeholder('Phone Number'),
    ])->sortable(),