F
Filamentβ€’6mo ago
ericmp #2

How to make Repeater unique fields name

I have a fields repeater. this fields have a name. the name must be unique. how to do it (,: ?
Repeater::make('fields')
->defaultItems(1)
->hiddenLabel()
->required()
->itemLabel(function (array $state): string {
return $state['name'] ?? '-';
})
->grid()
->cloneable()
->reorderable()
->label(__('Fields'))
->collapsible()
->addActionLabel(__('Add field'))
->schema([
Forms\Components\TextInput::make('name')
->required()
->label(__('Name'))
->live()
,
])
,
Repeater::make('fields')
->defaultItems(1)
->hiddenLabel()
->required()
->itemLabel(function (array $state): string {
return $state['name'] ?? '-';
})
->grid()
->cloneable()
->reorderable()
->label(__('Fields'))
->collapsible()
->addActionLabel(__('Add field'))
->schema([
Forms\Components\TextInput::make('name')
->required()
->label(__('Name'))
->live()
,
])
,
i tried to use the ->different() - https://filamentphp.com/docs/3.x/forms/validation#different but idk how to make it work since is inisde a repeater πŸ€”
No description
3 Replies
ericmp #2
ericmp #2β€’6mo ago
just tried ->different('../*/name') but seems doesnt do the trick haha (,:
ericmp #2
ericmp #2β€’6mo ago
god thanks πŸ™