Mstrihi
Mstrihi
FFilament
Created by Mstrihi on 9/12/2024 in #❓┊help
Fileupload field
No description
83 replies
FFilament
Created by Mstrihi on 8/3/2024 in #❓┊help
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:
Forms\Components\Repeater::make('projectQuestions')
->label(__('lang.project_questions'))->hiddenLabel()
->relationship('projectQuestions')
->schema([...])
->afterStateHydrated(function ($state, callable $set) {
if (empty($state)) {
$set('projectQuestions', getDefaultItems());
}
})
Forms\Components\Repeater::make('projectQuestions')
->label(__('lang.project_questions'))->hiddenLabel()
->relationship('projectQuestions')
->schema([...])
->afterStateHydrated(function ($state, callable $set) {
if (empty($state)) {
$set('projectQuestions', getDefaultItems());
}
})
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
FFilament
Created by Mstrihi on 7/24/2024 in #❓┊help
badge style issue V3
No description
12 replies
FFilament
Created by Mstrihi on 7/23/2024 in #❓┊help
I have problem with createOptionForm and columnSpan, not working correctly check screenshot.
No description
23 replies
FFilament
Created by Mstrihi on 7/11/2024 in #❓┊help
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