Filament RepeatableEntry Remove Label

ghz 8months ago ⋅ 61 views

RepeatableEntry::make('membership_records') ->schema([ TextEntry::make('created_at')->label("Date"), TextEntry::make('description'), ]) ->columns(2) ->inlineLabel(false) ->hiddenLabel() ->contained(false)

Answers

To remove the label starting from row number 2 in Filament 3, you can use the hiddenLabel() method combined with conditional rendering. Since Filament 3 uses Laravel Livewire, you can conditionally render the label based on the row number.

Here's how you can achieve it:

RepeatableEntry::make('membership_records')
    ->schema([
        TextEntry::make('created_at')->label("Date"),
        TextEntry::make('description'),
    ])
    ->columns(2)
    ->inlineLabel(false)
    ->hiddenLabel(function ($field, $index) {
        // Hide the label for rows starting from index 1 (second row)
        return $index > 0;
    })
    ->contained(false)

In the hiddenLabel() method, a closure is used to conditionally hide the label based on the row index ($index). The closure receives two parameters: the field and the index of the current row. By returning true when the index is greater than 0 (for rows starting from the second row), you effectively hide the label for those rows.