lucianosnchz
lucianosnchz
FFilament
Created by lucianosnchz on 11/28/2023 in #❓┊help
ItemLabel Repeater Index In Input
Hello! I'm encountering what seems to be a basic issue with the following: I'm working on a "static" repeater where repeaters already have a default number of items, and users only need to fill in the values. I've managed to set the Label for each item based on its index. However, now I want to automatically fill in the default value of the attribute_id field with the ID of each item in the repeater. Any suggestions on how I could achieve this? Thank you very much!
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()),

]),
3 replies
FFilament
Created by lucianosnchz on 10/17/2023 in #❓┊help
Chart Widget - Multiple results
No description
7 replies
FFilament
Created by lucianosnchz on 10/16/2023 in #❓┊help
Function AutoInvoke
Hello! I'm trying to adapt a function in the resource view. I want that when I access a record, I can set $record->is_read = 1; $record->save();, but I'm not sure where to place it. Is there an option for this? Thank you very much.
12 replies
FFilament
Created by lucianosnchz on 8/23/2023 in #❓┊help
Preload()
5 replies
FFilament
Created by lucianosnchz on 8/22/2023 in #❓┊help
Relationships Create Instance
4 replies