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
Dan Harrin
Dan Harrin2y ago
i dont think i understand
FACHRI
FACHRIOP2y ago
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.
FACHRI
FACHRIOP2y ago
i've found a way
FACHRI
FACHRIOP2y ago
but on the other hand this page doesn't work on filament repeater.
mszabeh
mszabeh2y ago
use similar this: ->options(Category::whereTaxonomy('product')->get()->pluck('name', 'id'))
toeknee
toeknee2y ago
Are you casting to array on save in the model for gender?
FACHRI
FACHRIOP2y ago
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.
toeknee
toeknee2y ago
Please show your model for that resource. I suspect you are not casting gender to array
FACHRI
FACHRIOP2y ago
for gender there is no problem. this is a new problem on the task list on
toeknee
toeknee2y ago
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.
FACHRI
FACHRIOP2y ago
does it need to be put in protected $casts ? previously I had mutate it to an array
toeknee
toeknee2y ago
if you do that then it will be stored as n array.. depends if you are filtering etc
FACHRI
FACHRIOP2y ago
I have tried this again, and the result is still an error.
FACHRI
FACHRIOP2y ago
FACHRI
FACHRIOP2y ago
FACHRI
FACHRIOP2y ago
when I don't fill in the repeater table section. this error does not occur.
Dan Harrin
Dan Harrin2y ago
do you have an array cast on your repeater field name in the model
FACHRI
FACHRIOP2y ago
FACHRI
FACHRIOP2y ago
FACHRI
FACHRIOP2y ago
repeater field name is not in my casts. only on attachments
Dan Harrin
Dan Harrin2y ago
put it in there then... it needs to be cast if its a repeater
FACHRI
FACHRIOP2y ago
like this ?
FACHRI
FACHRIOP2y ago
there are still error
Dan Harrin
Dan Harrin2y ago
try debugging it
toeknee
toeknee2y ago
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.
FACHRI
FACHRIOP2y ago
okay, sir. I will try it. so what is inside the repeater must be mutated to json (array casts) ?
FACHRI
FACHRIOP2y ago
i have changed select-multiple to json array. and it worked. thanks for the help, this is new knowledge for me in the future
FACHRI
FACHRIOP2y ago
there is another problem. why the data is not displayed here? select and attachment fields.
Want results from more Discord servers?
Add your server