-
-
Notifications
You must be signed in to change notification settings - Fork 546
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
Keys on Select Field Not Saved when a Key is 0
#2215
Comments
Might be duplicate of : #2066 |
Did you try |
That also prints the label, not the key. |
Looks like your label and key are the same though. What's in the blueprint file? |
My blueprint looks like this:
In the CP it looks like this: In the content file it looks like this:
|
Okay it's working as expected, except that options field in the CP is a bit weird. When your values are zero indexed like that, it just saves a simple array - like you have in your YAML file. Did you create the field through the CP or in the file? |
Ah. That makes sense. I created via the CP. |
Do you actually want those numbers to be the values? I think if you start from |
I do as I want to compare to |
0
Please keep this open. Also @robdekort I do consider this a bug. |
I don't think that would solve anything. In this comment #2215 (comment) you can see that the values are all being defined anyway. I think what might need to happen is to support an additional longer syntax for defining your options. options:
-
label: Sunday
value: 0
-
label: Monday
value: 1
-
label: Tuesday
value: 2
-
label: Wednesday
value: 3
-
label: Thursday
value: 4
-
label: Friday
value: 5
-
label: Saturday
value: 6 |
Ah sorry if I wasn't clear. You're right, just making the keys and labels mandatory won't solve anything. Of course the code would have to be changed so that the array keys are always interpreted as the values. Also when they are 0, 1, 2, etc. I really like your idea for an (additional) explicit syntax, as it is backwards compatible (since the old way is still supported) and also more intuitive when editing the yaml by hand. I'd also make it the default way for the select fieldtype to save the options. |
Bug Description
Labeled value (from select fieldtype inside a grid) has no key value.
I would expect that the key would be accessible as
{{ field:key }}
How to Reproduce
Try to get the key value from a select fieldtype.
Environment
Statamic version: 3.0.0.-beta-43
PHP version: 7.2.30
Install method (choose one):
statamic/statamic
The text was updated successfully, but these errors were encountered: