Skip to content

Fix: Select Default Falsy #194

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

Merged
merged 2 commits into from
Jul 3, 2025

Conversation

liamduckett
Copy link
Contributor

Hey, currently falsy default values do not function as expected for select inputs.

Consider the following example (included as a test):

$result = select(
    label: 'How many stars would you like to give?',
    options: ['3', '2', '1', '0'],
    default: '0',
);

I'd expect the highlighted option to be 0, but currently it is 3. This is because 0 is falsy - failing the if($this->default) check and resulting in the first option being highlighted by default.

My proposed fix for this, is to change the check to if($this->default !== null), allowing the following non-null falsy values to be used as defaults.

If this is merged, I'm happy to also look into other inputs that this may affect.

@liamduckett
Copy link
Contributor Author

Static analysis failure doesn't look related?

@taylorotwell taylorotwell merged commit dc07376 into laravel:main Jul 3, 2025
10 of 11 checks passed
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

Successfully merging this pull request may close these issues.

2 participants