Bonjoeri
Bonjoeri
FFilament
Created by Bonjoeri on 2/13/2025 in #❓┊help
Setting two keys from one select field and filling constant data
After asking in #saade-adjacency-list I found a solution
Hidden::make('label'),
Select::make('part_id')
->label('Part')
->options(fn() => Part::pluck('name', 'id'))
->searchable()
->afterStateUpdated(fn(Forms\Set $set, $state) => $set('label', Part::find($state)->name))
->required(),
Hidden::make('label'),
Select::make('part_id')
->label('Part')
->options(fn() => Part::pluck('name', 'id'))
->searchable()
->afterStateUpdated(fn(Forms\Set $set, $state) => $set('label', Part::find($state)->name))
->required(),
13 replies
FFilament
Created by Bonjoeri on 2/13/2025 in #❓┊help
Setting two keys from one select field and filling constant data
Is it something that filament handles or should i ask in the plugin channel?
13 replies
FFilament
Created by Bonjoeri on 2/13/2025 in #❓┊help
Setting two keys from one select field and filling constant data
No description
13 replies
FFilament
Created by Bonjoeri on 2/13/2025 in #❓┊help
Setting two keys from one select field and filling constant data
if there is a way to mutate the data specifically on the form in the adjacency list that would work as well but im not sure how to do that
13 replies
FFilament
Created by Bonjoeri on 2/13/2025 in #❓┊help
Setting two keys from one select field and filling constant data
im not the best at writing :p
13 replies
FFilament
Created by Bonjoeri on 2/13/2025 in #❓┊help
Setting two keys from one select field and filling constant data
I am wondering if what im doing is the correct way to do it and also the other comment i made.
//this id is now associated to the part_id key, I also want the name column to be bound to another key called 'label'
//I could do this by writing some logic in the mutateDataBeforeSave method but it would involve doing pluck again a second time
//and because this form is deeply nested into the model it would be quite a pain to write
->options(Part::pluck('name', 'id'))
//this id is now associated to the part_id key, I also want the name column to be bound to another key called 'label'
//I could do this by writing some logic in the mutateDataBeforeSave method but it would involve doing pluck again a second time
//and because this form is deeply nested into the model it would be quite a pain to write
->options(Part::pluck('name', 'id'))
13 replies
FFilament
Created by Bonjoeri on 2/13/2025 in #❓┊help
Setting two keys from one select field and filling constant data
having a way to mutate form data before save on the adjecencylist form would also work but i wasnt able to find one
13 replies
FFilament
Created by Bonjoeri on 2/13/2025 in #❓┊help
Setting two keys from one select field and filling constant data
This is the full form function on the resource page
public static function form(Form $form): Form
{
return $form
->schema([
AdjacencyList::make('part_locators')
->label('Parts')
->maxDepth(10)
->form([
Select::make('part_id')
->label('Part')
->options(Part::pluck('name', 'id'))
->searchable()
->required(),
TextInput::make('serial_number'),
]),

Select::make('customer_id')
->required()
->label('Customer')
->default(request()->query('customer_id'))
->options(Customer::pluck('company', 'id'))
->searchable(),
TextInput::make('system_name')->required(),
RichEditor::make('system_remarks'),
DatePicker::make('latest_software_update'),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
AdjacencyList::make('part_locators')
->label('Parts')
->maxDepth(10)
->form([
Select::make('part_id')
->label('Part')
->options(Part::pluck('name', 'id'))
->searchable()
->required(),
TextInput::make('serial_number'),
]),

Select::make('customer_id')
->required()
->label('Customer')
->default(request()->query('customer_id'))
->options(Customer::pluck('company', 'id'))
->searchable(),
TextInput::make('system_name')->required(),
RichEditor::make('system_remarks'),
DatePicker::make('latest_software_update'),
]);
}
13 replies