Grid::make('default')->schema([
Repeater::make('attributesRepeater')
->relationship('attributesRepeater')
->label('Atributos')
->itemLabel(function ($uuid, $component) {
$keys = array_keys($component->getState());
$index = array_search($uuid, $keys);
$attributes = $this->getOwnerRecord()->attributes;
return $attributes[$index]->name;
})
->schema([
TextInput::make('attribute_id')
->hidden()
->default($attributes[$index]->id),
Forms\Components\TextInput::make('value')
->required()
->label('Valor')
->live(onBlur: true)
->maxLength(255),
])
->grid(2)
->defaultItems($this->getOwnerRecord()->attributes->count()),
]),
Grid::make('default')->schema([
Repeater::make('attributesRepeater')
->relationship('attributesRepeater')
->label('Atributos')
->itemLabel(function ($uuid, $component) {
$keys = array_keys($component->getState());
$index = array_search($uuid, $keys);
$attributes = $this->getOwnerRecord()->attributes;
return $attributes[$index]->name;
})
->schema([
TextInput::make('attribute_id')
->hidden()
->default($attributes[$index]->id),
Forms\Components\TextInput::make('value')
->required()
->label('Valor')
->live(onBlur: true)
->maxLength(255),
])
->grid(2)
->defaultItems($this->getOwnerRecord()->attributes->count()),
]),