Display category to select field
hello, anyone can help me?
i want to display the contents of this category into a select field.
an example is the category of gender. will be displayed according to the contents in this category into the gender select field in another resource.
28 Replies
i dont think i understand
i have a resource called employee.
there are several fields. among others :
employee name, employee address, gender, etc
how do i display the category gender which has the content attached to the select field gender.
i've found a way
but on the other hand this page doesn't work on filament repeater.
use similar this:
->options(Category::whereTaxonomy('product')->get()->pluck('name', 'id'))
Are you casting to array on save in the model for gender?
i think the problem is in this repeater.
because when I haven't filled in the repeater section, this error hasn't occurred. here is the capture code.
Please show your model for that resource. I suspect you are not casting gender to array
for gender there is no problem. this is a new problem on the task list on
employee_id needs casting to array as it's a select, if you are not casting then you need to mutate it to an array when populating the list.
When you fill you see you are filling with a string but it's a select and expects an array.
does it need to be put in protected $casts ?
previously I had mutate it to an array
if you do that then it will be stored as n array..
depends if you are filtering etc
I have tried this again, and the result is still an error.
when I don't fill in the repeater table section. this error does not occur.
do you have an
array
cast on your repeater field name in the modelrepeater field name is not in my casts. only on attachments
put it in there then...
it needs to be cast if its a repeater
like this ?
there are still error
try debugging it
I've come across this before, selects are multi-possible and as such are saved as an array, casting allows them to save as an array but the column must be json or string. Then it won't populate if the data isn't mutated correctly i.e. if it's stored as a string but needs to be an array.
okay, sir. I will try it. so what is inside the repeater must be mutated to json (array casts) ?
i have changed select-multiple to json array. and it worked.
thanks for the help, this is new knowledge for me in the future
there is another problem. why the data is not displayed here? select and attachment fields.