Select field issue, HELP!!!
For some reason, category_id returns null when I try to save data.
31 Replies
Is it fillable?
Yes it is.
I don't see anything wrong in the select
So problem must lie somewhere else
Exactly
Could you see if the select gets outputted right in Filament?
You can use
$data
for that
dd() it after savingLike this?
It return null
The whole dd or category_id?
Just the category_id
Could you set the options manually?
With 1 option or so
Let me try it out
try
->default(Insert id of an existing category)
I tried it and it still return null
Did you select a value?
Let me try it
I did
This also returned null
The other values of $data are good?
@awcodes Hello 😩
Don't tag maintainers
No one is obligated to help you
I know. That's why I added the emoji
Weird
Did you add the category_id to the save function?
I noticed now it is a livewire component
Exactly, I'm using form and table builder.
I dumped the whole
$this->form->getState()
What if you use a TextInput class instead of the Select class and enter the ID as a number there?
Can you give me a code example please? I can't picture what you mean since the categories are being fetched from the database.
TextInput::make('category_id'),
Solved. Issue came from adding searchable() to the Select element
It should also work with
searchable()
.It should but it's slowing me down at the moment so I'll look into it later
Solution
Did you do the mount method?
It worked perfectly