Existing data not showing in the select box.
When I click on a record to edit it, the select boxes do not show the data which should be there. This is my code
12 Replies
What does your edit firing code look like ?
What do you mean? This is just when you click on a record. The select fields should show the existing value but instead they're not set.
Yes, but you'll have had to include something to make that click an action.
In your resource, what does your chained method contain in the function?
You mean this?
What select?
Are you using the panel builder or only the form builder?
panel builder
Its inside the Resource
Levels have Grades which have Sections
Student belongs to a Section
I made it work by defining a relationship between Student and Grade, and Student and Level
but its redundant because a student already belongs to a section, and the section belongs to grade which belongs to level
panel builder
I did check that, but i have a third degree dependency
hope you understand
like first i want to choose the level, which will show the relavant grades, which will then show the relavant sections
Level and Grade are not related to the Student directly, but through Section
are you using Filament v2?
Not related to the issue, but double-check your code if you are using Filament v3. reactive() and callable are used in v2.
Ensure your select query returns the expected results..
So do level_id, grade_id & section_id sit as columns in the Student model?
V3
Currently yes, to make it work properly. Else ideally I'd like just the section_id in the student model
I think for a filament form to be able to fetch a value, it needs to be a column in the table, and since grade and level aren't in the table but referenced through section, it is not able to fetch the value
which explains why it works when i add the grade and level column to student
makes it redundant in a way but can't see any other way
No. The way you've coded it, it needs to be in the table.
You need to to learn how Filament accesses relationships: https://filamentphp.com/docs/3.x/forms/advanced#saving-data-to-relationships