Replies: 1 comment 1 reply
-
If it ignores and considers as False then Use '2' (Non zero value) instead of 0. This solved my issue. Thanks. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm in the process of migrating a project from laravelcollective/html to spatie/laravel-html, and I've hit a snag with radio buttons. Specifically, we have a number of places where the radio button is to switch between a value of 1 and 0. These should default to be unset when the form is blank, but it is always defaulting to checking the 0 option, no matter what value I put in the $checked boolean argument. For example:
Yields this result:
Even doing
html()->radio('public', true, 1)
andhtml()->radio('public', false, 0)
yields the same result. This is especially problematic when I want the default to be the first option. Best workaround I can come up with is to chain the ->checked() method to the end, but that gets tedious doing the long-form check for model and old values.The problem seems to lie in the
$this->old($name) == $value
comparison in the radio() method, in which 0 == null evaluates to true. I was going to attempt a PR for this, but it seems a bit sticky, especially given that, while it would be a bug fix, it's also potentially a breaking change for some implementations.Beta Was this translation helpful? Give feedback.
All reactions