CheckBoxList, Enums and TextColumn display conundrum
Salut
Interesting little problem. I have a Checkbox list on the form that is populated with an Enum. This all fine and works as expected - the labels are displayed and the values are stored correctly:
On the table I want to display the the selected values
Which is where the problem arises - the column displays the stored value and not the label.
Because this is a multi-value field , stored as JSON in the model I need to cast it to
If this were a simple/single value field (e.g CheckBox or Select) then I could cast it to the enum
So how do I cast the field to an array and still have the Enum return the correct labels in the table column?
Thanks for reading this far!
My enum for reference
Interesting little problem. I have a Checkbox list on the form that is populated with an Enum. This all fine and works as expected - the labels are displayed and the values are stored correctly:
On the table I want to display the the selected values
Which is where the problem arises - the column displays the stored value and not the label.
Because this is a multi-value field , stored as JSON in the model I need to cast it to
type => 'array'If this were a simple/single value field (e.g CheckBox or Select) then I could cast it to the enum
type => OrganisationTypes::class and the correct label would be displayed in the table column. So how do I cast the field to an array and still have the Enum return the correct labels in the table column?
Thanks for reading this far!
My enum for reference
Solution
Try https://filamentphp.com/docs/3.x/forms/advanced#field-hydration
Something like below should work. not tested code
Something like below should work. not tested code