Make only specific repeater elements non-deletabel

Hi, I wonder if it is currently possible to make only specific repeater items nonDeletable
public static function getItemsRepeater(): Repeater
{
return Repeater::make('orderItems')
->relationship('orderItems') // This links the Repeater to the hasMany relationship on Order
->schema([
Grid::make(['md' => 12])->schema([
TextInput::make('quantity')
->label('Quantity')
->numeric()
->default(1)
->required()
->suffix('pcs')
->columnSpan(['md' => 2])
......

TextInput::make('meta')
->label('Meta')
->columnSpan(['md' => 2])
,
])->disabled(fn($get) => filled($get('invoice_id')))
,
])
->deletable(fn($get) => blank($get('invoice_id'))) // <- This disables delete button
->defaultItems(0)
->hiddenLabel()
->columns(['md' => 10]);
}
public static function getItemsRepeater(): Repeater
{
return Repeater::make('orderItems')
->relationship('orderItems') // This links the Repeater to the hasMany relationship on Order
->schema([
Grid::make(['md' => 12])->schema([
TextInput::make('quantity')
->label('Quantity')
->numeric()
->default(1)
->required()
->suffix('pcs')
->columnSpan(['md' => 2])
......

TextInput::make('meta')
->label('Meta')
->columnSpan(['md' => 2])
,
])->disabled(fn($get) => filled($get('invoice_id')))
,
])
->deletable(fn($get) => blank($get('invoice_id'))) // <- This disables delete button
->defaultItems(0)
->hiddenLabel()
->columns(['md' => 10]);
}
3 Replies
toeknee
toeknee5w ago
Yes you can use $get() I just tested it working well.
Glennynator
GlennynatorOP5w ago
Hi Toeknee, thanks for your reply. I think I missed some important details. The invoice_id is filled per orderItem. So only for orderItems that have an invoice_id filled, remove this delete button. So some lines will have no button and some have. I hope this is clear to you.
toeknee
toeknee4w ago
Sorry it's not making much sense. Can you clarify what items should not be deletable

Did you find this page helpful?