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

[1.0.23] flux:select: option with empty value sets the option label as value and not the empty value #665

Closed
lucasromanojf opened this issue Nov 13, 2024 · 1 comment

Comments

@lucasromanojf
Copy link

Hello,

When using a flux:select which has an option of empty value, if I select this option, the binded model is set with the option label and not with an empty string. It was working fine on previous versions.

You can see in the following example that, when selecting the first option, $value variable is set to "Select one" and not to "" (empty).

<?php

use function Livewire\Volt\{state};

state([
    'value' => '',
    'options' => [
        ['value' => '', 'label' => 'Select one'],
        ['value' => '1', 'label' => 'Option 1'],
        ['value' => '2', 'label' => 'Option 2'],
        ['value' => '3', 'label' => 'Option 3'],
    ],
])->url();

?>

<div>
    <flux:select variant="listbox" wire:model.live="value">
        @foreach ($options as $option)
            <flux:option :key="$option['value']" wire:key="{{ $option['value'] }}" :value="$option['value']">
                {{ $option['label'] }}
            </flux:option>
        @endforeach
    </flux:select>

    Selected option value: {{ $value }}
</div>
@calebporzio
Copy link
Contributor

Ah good catch, yeah there were two bugs that worked in combination on this one. Fixed and will be in the next release. Thanks!

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

2 participants