TALL-forms
  • TALL-forms
  • Installation
    • Quickstart: Artisan cmd
    • Manual installation
      • Package
      • Translations
      • Css & Theme
      • Javascript
      • Tailwind
      • Laravel Mix
      • Wrapper view
      • Laravel Jetstream/Breeze
  • Upgrade v7 to v8
    • Configuration changes
    • Component & Field changes
    • Blade view changes
    • Notification changes
    • Styling changes
  • Concept
    • Configuration
    • Validation
    • Styling
    • Icons
    • Javascript
    • Layout vs Wrapper
    • Model binding
    • Manually saving data
    • Extend Blade Components
  • Create Forms
    • Form Data
    • Form Types
      • Standard form
      • As modal
      • Without buttons
      • Fields only
      • Headless
    • Form attributes
    • Form buttons
    • Form slots
    • Form methods
    • Lifecycle hooks
    • Render a form
    • Mass generate
  • Fields
    • Declaration
    • Labels
    • Field Slots
    • Field methods
    • Custom field attributes
    • Conditional field
    • Custom view
    • Custom field
    • Custom Livewire component
    • Relations
    • Fields
      • Checkbox
      • Checkboxes
      • FileUpload
      • Honeypot
      • ImageCropper
      • Input
      • Password
      • InputArray
      • KeyVal (array)
      • Radio
      • Range
      • Repeater (array)
      • Search
      • Select & Multiselect
      • Tags
      • TagsSearch
      • Textarea
      • Trix
      • SpatieTags
    • Sponsor Fields
      • More Inputs
      • CKEditor
      • DatePicker
      • Heading
      • Markdown
      • Panels
      • SearchList
      • SelectOptGroup
      • Tabs
      • Trix, file-uploads
  • Blade components
    • Notifications
    • Label wrapper
    • Button
    • Modal blade component
    • Modal form blade component
  • Examples
    • Input examples
    • Array fields example
Powered by GitBook
On this page
  • Methods
  • ->fields($fields = [ ])
  • ->labelEachRow()
  • ->sortable()
  • ->wrapperClass(string $classes)
  • ->wrapperGrid(string $classes)
  • ->childColspan(int $cols)
  • ->childStacked()
  • ->childInline()
  • ->wire(string $wire_model_declaration)
  • ->confirmDelete(string $message = '')

Was this helpful?

  1. Fields
  2. Fields

Repeater (array)

PreviousRangeNextSearch

Last updated 3 years ago

Was this helpful?

Repeater::make('Friends')->fields([
    Input::make('First name')
        ->afterLabel('After Label slot')
        ->rules('required'),
    Input::make('Last name')
        ->afterLabel('Best slot to display field help')
        ->rules('required'),
])
    ->sortable()
    ->rules('required')
    ->help('Click plus to add a friend')
    ->confirmDelete()
    ->default([[]]) // show empty item by default
    ->childColspan(6)
    //->labelEachRow() repeat labels above each iteration

Show an empty item by default

Set an empty array item as ->default() to be displayed if the field value is empty.

Repeater::make('Your repeater')
    ->fields([ your fields here ])
    ->default([[]])

Use updatedFoo() hook to add an empty array if the users deletes the empty item

public function updatedYourRepeater($value) {
    if(blank($value)) data_set($this, 'form_data.your_repeater', [[]]);
}

Not supported. Check the source in resources/views/includes/array-wrapper.blade.php if you want to replicate the layout, manually.

You can change the default blade views for the icons in the config file.

//icons
'arrow-up-icon' => 'icons.cheveron-outline-up',
'arrow-down-icon' => 'icons.cheveron-outline-down',
'trash-icon' => 'icons.close-outline',

Methods

->fields($fields = [ ])

You can use almost any field type, an error will be thrown if you use an invalid field.

->labelEachRow()

  • Show all field slots (labels and more) on every iteration.

  • Without this, the label will only be displayed above the first row.

->sortable()

Makes the array sortable. Show buttons to change the order of the array items. (See the image)

->wrapperClass(string $classes)

  • Applied to the outer wrapper surrounding the Repeater field group

  • Default: 'flex flex-col divide-y mb-2 rounded border'

->wrapperGrid(string $classes)

  • Defines the css grid for the Repeater field group

  • Default: 'flex-1 sm:grid sm:grid-cols-12 gap-x-2'

->childColspan(int $cols)

  • Overrides nested $field->colspan()

  • Default 12 of 12 columns

  • If you set it on the Panel you do not have to set it on each nested field.

->childStacked()

  • Apply $field->stacked() to all nested fields, can be overridden in each field.

->childInline()

  • Apply $field->inline() to all nested fields, can be overridden in each field.

->wire(string $wire_model_declaration)

  • Override nested fields wire:model attribute.

->confirmDelete(string $message = '')

  • Show an alert to confirm item deletion.

  • Custom message

  • Default message = config translation string 'are-u-sure'

Default mode is to display labels above the first iteration
Or you can repeat the labels on each item