Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flux option group - using boolean not working #73

Open
codeldev opened this issue Sep 25, 2024 · 4 comments
Open

Flux option group - using boolean not working #73

codeldev opened this issue Sep 25, 2024 · 4 comments

Comments

@codeldev
Copy link

I have seen this closed issue here #42 , however I cannot seem to get this working for the following:

<flux:radio.group
    wire:model.boolean="form.use_system_mailer"
    :label="trans('config.mailer.system')"
    :description="trans('config.mailer.system.helper')">
    <flux:radio 
        value="true"
        :label="trans('config.mailer.system.yes')" />
    <flux:radio
        value="false"
        :label="trans('config.mailer.system.no')" />
</flux:radio.group>

In the above, nothing is showing as checked even when form.use_system_mailer is loaded as true/false.

I have other form fields on the page which show/hide based on the selected radio via $wire.form.use_system_mailer, but these are not being triggered to show/hide.

Removing the boolean from the wire:model doesn't help either.

Any help appreciated!

@codeldev
Copy link
Author

Just to add, that in the livewire component:

public MailerConfigForm $form;

in that file:

#[Validate(['required', 'boolean'])]
public bool $use_system_mailer = true;

@lghcdh
Copy link

lghcdh commented Sep 26, 2024

Some additional information. I decided to test the radio group with integers and regular strings. Results as follows:

Livewire Component

    #[Validate(['required', 'string'])]
    public string $with_string = '1';

    #[Validate(['required', 'integer'])]
    public int $with_integer = 1;

    #[Validate(['required', 'boolean'])]
    public bool $with_boolean = false;

Blade component

    {{-- Works: YES --}}
    <flux:radio.group wire:model="with_string" label="Works with a string?">
        <flux:radio value="1" label="Yes" />
        <flux:radio value="0" label="No" />
    </flux:radio.group>

    <flux:separator />
    
    {{-- Works: NO --}}
    <flux:radio.group wire:model.number="with_integer" label="Works with an integer?">
        <flux:radio value="1" label="Yes" />
        <flux:radio value="0" label="No" />
    </flux:radio.group>

    <flux:separator />
    
    {{-- Works: NO --}}
    <flux:radio.group wire:model.boolean="with_boolean" label="Works with a boolean?">
        <flux:radio value="true" label="Yes" />
        <flux:radio value="false" label="No" />
    </flux:radio.group>

Only seems to work with strings. Using integers or booleans along with the required modifier do not work. Hope that helps.

@bzarzuela
Copy link

Yup, I have this issue as well.

Using :value="true" doesn't work either. I hoped it would cast to a primitive so that the check will pass but no luck.

@satoved
Copy link

satoved commented Sep 28, 2024

I have troubled with integers as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants