F
Filament7mo ago
Sidem

select didn't return id

Hi everyone, I have a problem : my select didn't return any id ;
Select::make("produits.type_{$value}[]")
->label("type product {$value}")
->options([
TypeProduct::all()->pluck('name', 'id')->toArray()
])
->multiple()
->searchable()
->columnSpan(2),
Select::make("produits.type_{$value}[]")
->label("type product {$value}")
->options([
TypeProduct::all()->pluck('name', 'id')->toArray()
])
->multiple()
->searchable()
->columnSpan(2),
and this is my return (image) Thanks
No description
12 Replies
LeandroFerreira
LeandroFerreira7mo ago
is it a custom page?
Sidem
SidemOP7mo ago
nop it's in my Product Resource.php, in a Grid
LeandroFerreira
LeandroFerreira7mo ago
->options(TypeProduct::pluck('name', 'id')->toArray())
->options(TypeProduct::pluck('name', 'id')->toArray())
Sidem
SidemOP7mo ago
after updated my code :
Select::make("products.type_{$value}[]")
->label("Product type {$value}")
->options(
TypeProduct::all()->pluck('name', 'id')->toArray()
)
->multiple()
->searchable()
->columnSpan(2),
Select::make("products.type_{$value}[]")
->label("Product type {$value}")
->options(
TypeProduct::all()->pluck('name', 'id')->toArray()
)
->multiple()
->searchable()
->columnSpan(2),
i have the same error same if i remove the [] :
php Select::make("products.type_{$value}")
php Select::make("products.type_{$value}")
LeandroFerreira
LeandroFerreira7mo ago
where is the dd(..)?
Sidem
SidemOP7mo ago
in my model, in the function create()
LeandroFerreira
LeandroFerreira7mo ago
https://filamentphp.com/docs/3.x/panels/resources/creating-records#lifecycle-hooks try beforeCreate hook in the CreatePage to check the form values:
protected function beforeCreate(): void
{
dd($this->data);
}
protected function beforeCreate(): void
{
dd($this->data);
}
Sidem
SidemOP7mo ago
wtf now he disappeared
No description
LeandroFerreira
LeandroFerreira7mo ago
take another look at your code..
Sidem
SidemOP7mo ago
Select::make("products.type_{$value}[]")
->options(
TypeProducts::all()->pluck('name', 'id')->toArray()
)
->multiple()
->searchable()
->columnSpan(2),

TextInput::make("products.name_{$value}")
->required()
->columnSpan(2),

TextInput::make("products.value_{$value}")
->integer()
->minValue(1)
->required()
->columnSpan(2)
Select::make("products.type_{$value}[]")
->options(
TypeProducts::all()->pluck('name', 'id')->toArray()
)
->multiple()
->searchable()
->columnSpan(2),

TextInput::make("products.name_{$value}")
->required()
->columnSpan(2),

TextInput::make("products.value_{$value}")
->integer()
->minValue(1)
->required()
->columnSpan(2)
and in my ProductResource/pages/createProduct.php i put the
protected function beforeCreate(): void
{
dd($this->data);
}
protected function beforeCreate(): void
{
dd($this->data);
}
LeandroFerreira
LeandroFerreira7mo ago
Did you try without {$value}?
Sidem
SidemOP7mo ago
i need to generate x select depends of a variable that why i use {$value] but i will try
Want results from more Discord servers?
Add your server