PHP code example of yousefaman / filament-modal-repeater

1. Go to this page and download the library: Download yousefaman/filament-modal-repeater 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/ */

    

yousefaman / filament-modal-repeater example snippets


use YousefAman\ModalRepeater\ModalRepeaterPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(ModalRepeaterPlugin::make());
}

use YousefAman\ModalRepeater\ModalRepeater;
use YousefAman\ModalRepeater\Column;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Toggle;

ModalRepeater::make('items')
    ->tableColumns([
        Column::make('name')->label('Name'),
        Column::make('price')->money('USD'),
        Column::make('active')->boolean(),
    ])
    ->schema([
        TextInput::make('name')->

// Custom label
Column::make('name')->label('Product Name'),

// Boolean — renders a checkmark/cross icon
Column::make('active')->boolean(),

// Badge — renders a colored badge using the value
Column::make('status')->badge('success'),

// Money — formats the value as a currency amount
Column::make('price')->money('USD'),

// Custom formatter
Column::make('created_at')->formatUsing(fn ($value) => $value->diffForHumans()),

// Fixed column width
Column::make('name')->width('200px'),

ModalRepeater::make('items')
    ->modalColumns(3)     // Number of columns in the modal form grid
    ->modalWidth('4xl')   // Tailwind modal max-width (e.g. 'sm', 'lg', '4xl', '7xl')

ModalRepeater::make('addresses')
    ->relationship('addresses')
    ->tableColumns([
        Column::make('street')->label('Street'),
        Column::make('city')->label('City'),
        Column::make('postcode')->label('Postcode'),
    ])
    ->schema([
        TextInput::make('street')->

ModalRepeater::make('items')
    // Change the label on the "Add" button
    ->addActionLabel('Add Item')

    // Customize the edit action
    ->editAction(
        fn (Action $action) => $action->label('Edit')->icon('heroicon-o-pencil')
    )

    // Append additional per-row actions
    ->extraItemActions([
        Action::make('duplicate')->action(fn ($arguments) => ...),
    ])

    // Text shown when the list is empty
    ->emptyLabel('No items added yet.')

    // Allow rows to be reordered via drag-and-drop
    ->reorderable()

    // Allow rows to be cloned
    ->cloneable()

    // Prevent deletion
    ->deletable(false)
bash
php artisan modal-repeater:install