-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
Numeric select options #1357
Comments
This is not really a Kirby bug, but a PHP stupidity. You can create an array with number strings as keys and it will automatically convert the strings to ints, which is super annoying. There's a new feature in Kirby 3 for selects, radios and checkboxes, which makes it possible to declare options like this:
which is often a lot more useful than repeating the value just to create the key, which would have been required in v2.
But the only way to make this work is to check for integers as keys vs strings. That's where your setup fails. You can work around this by using the long form though:
|
Cool, thanks! |
Same problem here, although using the suggested solution with value and text, numerical values are not working. When saving the page in the panel, the value is not stored. Did it work out for you, @nilshoerrmann ? Version: 3.0.0 |
I just tested this and it works if you wrap the numbers in quotes
|
Thanks @texnixe!
|
@hentrev Yes, but the whole issue was about displaying some meaningful text to accompany the numbers. |
We can then probably close this? |
Sure, thanks for the quick support. |
@texnixe: Will you add this to the docs? |
Already has been :) |
Perfect! Thanks a lot. |
I'm personally annoyed with the need to use the longhand form for this. Would any of these two workarounds be considered? Non-Zero Key: Con: If you actually do want to start at Padded String Keys: options:
'300 ': '300: Multiple Choices'
' 301': '301: Moved Permanently' Mixed Approach: options:
'0 ': 'Some value'
'300': '300: Multiple Choices'
'301': '301: Moved Permanently' |
Describe the bug
Expected behavior Kirby Version |
@vauvarin If you wrap the text in quotes as well, it works.
Or if you only use numbers like in your example, use the short form: #1357 (comment) |
i am trying to hook into an api and use IDs for countries and it fails on me, too: country_id: |
Describe the bug
When setting up select field options, Kirby ignores numeric keys:
It doesn't matter if the keys are wrapped in quotes or not. Kirby will always use the text as value, storing
300: Multiple Choices
instead of300
.Expected behavior
Kirby should use the given keys. K2 seems to have handled this correctly when keys where wrapped in quotes.
Kirby Version
K3 Golden Master
The text was updated successfully, but these errors were encountered: