Kitty
Kitty
FFilament
Created by Kitty on 6/14/2024 in #❓┊help
How do you add processing spinner to wizard button?
As an example, in a wizard the next button has a processing spinner but the submit does not, how do I add it to the submit?
Wizard::make($steps)
->submitAction(new HtmlString(Blade::render(
<<<'BLADE'
<x-filament::button
type="submit"
size="xl"
color="primary"
>

{{trans('Start Questionnaire')}}
</x-filament::button>
BLADE
)))
->nextAction(
fn (Action $action) => $action->color('primary'),
)
Wizard::make($steps)
->submitAction(new HtmlString(Blade::render(
<<<'BLADE'
<x-filament::button
type="submit"
size="xl"
color="primary"
>

{{trans('Start Questionnaire')}}
</x-filament::button>
BLADE
)))
->nextAction(
fn (Action $action) => $action->color('primary'),
)
29 replies
FFilament
Created by Kitty on 6/13/2024 in #❓┊help
Problem with afterStateHydrated
In a custom page, I am trying to set my toggle buttons default value based on its dynamic options. The options are based on different field values. I have tried both default() and afterStateHydrated(). Even though I can populate the options correctly, I can not access the fields options in either of those methods when the options are dependent on other fields. How can I fix this? Assume: $get('dob') = '02/20/2022' and $get('prematurity_id') = '02/30/2022' This correctly gets the options
ToggleButton::make('questionnaire_id')
->options( fn (Get $get) =>
self::getQuestionnaireOptions($get('dob'), $get('prematurity_id'))
)
->inline()
->label(trans('Select Questionnaire'))
->required(),
ToggleButton::make('questionnaire_id')
->options( fn (Get $get) =>
self::getQuestionnaireOptions($get('dob'), $get('prematurity_id'))
)
->inline()
->label(trans('Select Questionnaire'))
->required(),
Trying to set the default, but $component->getOptions() returns null
ToggleButton::make('questionnaire_id')
->options( fn (Get $get) =>
self::getQuestionnaireOptions($get('dob'), $get('prematurity_id'))
)
->afterStateHydrated(function (ToggleButton $component) {
$component->state(array_key_first($component->getOptions()));
})
->inline()
->label(trans('Select Questionnaire'))
->required(),
ToggleButton::make('questionnaire_id')
->options( fn (Get $get) =>
self::getQuestionnaireOptions($get('dob'), $get('prematurity_id'))
)
->afterStateHydrated(function (ToggleButton $component) {
$component->state(array_key_first($component->getOptions()));
})
->inline()
->label(trans('Select Questionnaire'))
->required(),
If I don't try to GET the value from other fields, this correctly sets the default
ToggleButton::make('questionnaire_id')
->options( fn (Get $get) =>
self::getQuestionnaireOptions('02/20/2022', '02/30/2022')
)
->afterStateHydrated(function (ToggleButton $component) {
$component->state(array_key_first($component->getOptions()));
})
->inline()
->label(trans('Select Questionnaire'))
->required(),
ToggleButton::make('questionnaire_id')
->options( fn (Get $get) =>
self::getQuestionnaireOptions('02/20/2022', '02/30/2022')
)
->afterStateHydrated(function (ToggleButton $component) {
$component->state(array_key_first($component->getOptions()));
})
->inline()
->label(trans('Select Questionnaire'))
->required(),
11 replies
FFilament
Created by Kitty on 4/25/2024 in #❓┊help
Searchable & Required Select Bug
When using a select field with searchable and required in a Livewire custom page the required validation fails. Removing the searchable and it works. It also works fine in a resource panel. Code Forms\Components\Select::make('zipcode_id') ->relationship('zipcode', 'zipcode') ->label('Your Oregon Zipcode') ->required() ->searchable(), In the custom page, I can search and it fills the field with the value but is still fails the required validation so doesn't save and I get the required error message. File: https://github.com/griggsk/osp/blob/main/CreateChild.php Line 92 is where the zip is Console errors When selecting: - Uncaught TypeError: this.select is null - Uncaught (in promise) TypeError: this.select is null Any ideas on how to fix? Thanks
3 replies
FFilament
Created by Kitty on 1/26/2024 in #❓┊help
Repeater Relationship missing :condition
What I am trying to do: Not Create Empty Repeater Relationships What I Tried: Using the :condition variable. HasOne components have a :condition variable on the ->relationship method that allows you to set the field as optional so that the form does not try to create the relationship with an empty value. But it seems the HasMany Repeater does not support this variable. What I would like help with: Q: Is this to be expected? Q2: How can I make a repeater be optional? Note: I would prefer to set default to 1 and not create empty relationships.
Example: Works Forms\Components\Group::make() ->relationship( 'childFamilyIncome', condition: fn (?array $state): bool => filled($state['family_income_id']), ) ->schema([ ... ]) Example: Doesn't work. Error Unknown named parameter $condition Forms\Components\Repeater::make('childEthnicities') ->relationship('childEthnicities', condition: fn (?array $state): bool => filled($state['ethnicity_id'])) ->label('Child Ethnicities') ->simple( ... ) ->defaultItems(1)
2 replies