PHP code example of mikkimike / orchid-repeater-field

1. Go to this page and download the library: Download mikkimike/orchid-repeater-field library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mikkimike / orchid-repeater-field example snippets


 
 
 namespace App\Http\Orchid\Layouts\Repeaters;
 
 use Orchid\Screen\Layouts\Rows;
 use Orchid\Screen\Fields\Input;
 use Orchid\Screen\Fields\Select;
 
 class RepeaterFields extends Rows
 {
     function fields(): array
     {
         return [
             Input::make('repeater_name')
                 ->type('text')
                 ->max(255)
                 ->

public function layout(): array
{
   return [
       Layout::rows([
           RepeaterField::make('repeater')
               ->title('Repeater')
               ->layout(App\Http\Orchid\Layouts\Repeaters\RepeaterFields::class),
       ])
   ];
}

RepeaterField::make('repeater')
    ->title('Repeater')
    ->layout(App\Http\Orchid\Layouts\Repeaters\RepeaterFields::class)
    ->

RepeaterField::make('repeater')
    ->title('Repeater')
    ->layout(App\Http\Orchid\Layouts\Repeaters\RepeaterFields::class)
    ->buttonLabel('Add new repeater field')




namespace App\Orchid\Layouts;

use Nakukryskin\OrchidRepeaterField\Traits\AjaxDataAccess;
use Orchid\Screen\Layouts\Rows;
use Orchid\Screen\Fields\Input;
use Orchid\Screen\Fields\Select;

class RepeaterFields extends Rows
{
    use AjaxDataAccess;

    public function fields(): array
    {
        return [
            Select::make('select.')
                ->title('Select')
                ->multiple()
                ->options($this->getSelectOptions())
                ->


Repeater::make('repeater')
      ->title('Repeater')
      ->layout(\App\Orchid\Layouts\RepeaterFields::class)
      ->ajaxData(function () {
          $data = [
              'select_options' => [
                  'default' => 'Default option',
              ],
          ];
   
          if (request()->user()->id === 1) {
              $data['select_options']['only_first'] = 'Option only for user with id #1';
          }
   
          return $data;
      }),

Repeater::make('repeater')
         ->title('Repeater')
         ->layout(\App\Orchid\Layouts\RepeaterFields::class)
         ->ajaxData([
             'select_options' => [
                 'default' => $this->query()['name'] ?? 'Default Name',
             ],
         ]),