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

Tighten up the Select (and Select-ish) fieldtypes #4483

Merged
merged 9 commits into from
Oct 15, 2021

Conversation

jasonvarga
Copy link
Member

@jasonvarga jasonvarga commented Oct 13, 2021

Fixes a bunch of stuff related to "select-ish" fieldtypes: select, radio, checkboxes, button_group. The ones that have options.

  • When a field has a value that isn't in the options, the label is the value, instead of getting an error. Fixes Migrating v2 pages with false values for selects results in an error exception #4204
  • When you have cast_booleans enabled, null can also have a label. (Even though it's not technically a boolean)
  • Fixed how they're rendered in listings.
  • When you're using booleans, and you have a false, you can use {{ field:label }} to get the label.
  • Extract the common bits to traits.
  • Add tests and extract them to traits.
  • Fixes how they're rendered in listings

@FrittenKeeZ
Copy link
Contributor

Won't true also cause issues when just checking if it's truthy?

@jasonvarga
Copy link
Member Author

What issue are you seeing?

@FrittenKeeZ
Copy link
Contributor

If you pass true into $value ? array_get($this->config('options'), $value, $value) : $value, you'll get the same type error

@jasonvarga
Copy link
Member Author

Ah yeah I didn't notice since I was checking using PHP8 which doesn't show that error. I see it on 7.4. 👍

@jasonvarga jasonvarga changed the title Fix handling of invalid values in select fields Tighten up the Select (and Select-ish) fieldtypes Oct 15, 2021
@jasonvarga jasonvarga marked this pull request as ready for review October 15, 2021 20:50
@jasonvarga jasonvarga merged commit 7021a6d into 3.2 Oct 15, 2021
@jasonvarga jasonvarga deleted the fix/4204-select-fieldtype-invalid-value branch October 15, 2021 20:52
@FrittenKeeZ
Copy link
Contributor

FrittenKeeZ commented Oct 18, 2021

Really good work 👍

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.

Migrating v2 pages with false values for selects results in an error exception
2 participants