Mstrihi
Issue with Default Items in Edit Mode for Questions Step
Hi everyone,
I'm encountering an issue with a form in FilamentPHP, specifically in the
questions
step. The form works perfectly in create mode but not in edit mode. Here’s a summary of the code and the problem I’m facing.
Code Overview:
1. getDefaultItems Method:
- Retrieves parent and child questions from the database.
- Creates an array of default items.
2. Form Configuration for Questions Step:
- A Wizard Step with a Repeater for projectQuestions
.
- Contains parent_id
, answer
, conditional image
, and description
fields.
- Nested Repeater for childQuestions
with conditional fields.
Code link: GitHub Gist
Problem Description:
- In create mode, the form initializes correctly.
- In edit mode, default items are not loaded properly.
I tried adding the afterStateHydrated
method to call getDefaultItems
in the main repeater. This works, but if there's already saved data, it doesn't load correctly because getDefaultItems
returns the default data.
Here’s an example of my attempt:
Issue:
In edit mode, default items are set instead of loading saved data from the database.
Question:
How can I ensure that in edit mode, the form loads existing saved data correctly and only sets default items if the form is empty?
Any help or pointers would be greatly appreciated.
Thank you!5 replies
Hi, please help with this. why I get this error ?
Method Filament\Infolists\Components\Section::headerActions does not exist.
used same example from https://filamentphp.com/docs/3.x/infolists/layout/section
77 replies