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
is it a custom page?
Sidem
Sidem5w ago
nop it's in my Product Resource.php, in a Grid
LeandroFerreira
->options(TypeProduct::pluck('name', 'id')->toArray())
->options(TypeProduct::pluck('name', 'id')->toArray())
Sidem
Sidem5w 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
where is the dd(..)?
Sidem
Sidem5w ago
in my model, in the function create()
LeandroFerreira
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
Sidem5w ago
wtf now he disappeared
No description
LeandroFerreira
take another look at your code..
Sidem
Sidem5w 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
Did you try without {$value}?
Sidem
Sidem5w 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
More Posts