-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
select field with structure query does not save passed value #5013
Comments
@lukasbestle I've track down the issue and this is related about strict comparison. Option text and values return as string and the page tried to update with
@jaro-io I'm not sure that this is bug or not but you can use like $page->update([ 'select' => '0' ]); |
thank you so much @afbora, passing a |
As I said, I'm not sure about this is bug or not. I think the reason of different behaviors are using different native functions. |
@afbora You mean the strict I'm wondering if there is a use case where a value for one of those fields should ever be something else than a string. At least in core usage, the value is stored in a content file, so any other type than @distantnative You have a better overview here, what do you think? |
Exactly! We have same bug for fields using |
I think @lukasbestle is right. I can't imagine a case where we have a range of options to compare against and it would be not ok to cast the value to string before comparing it to the options. But, @lukasbestle, do you see any advantage in casting value to a string over just removing the strict flag from |
@distantnative Using |
hey @distantnative 🌳 seems like this issue is not resolved yet. i’ve just manually integrated #5761 into my additionally, in structure.mp4the field setup in this example is just like before and very simple to reproduce:
# structure
structure:
type: structure
fields:
title:
type: text
# select
select:
type: select
options:
type: query
query: page.structure.toStructure
text: '{{ structureItem.title }}' |
Wondering if your problem now is more related to #5702 or if it also occurs if you have integer values/keys not coming form structure fields. |
@distantnative yup, that seems to be exactly what i am experiencing with |
@jaro-io can you please try if it is resolved if you replace |
@distantnative yup, it does! 🤗 |
🎉 thanks for testing |
@distantnative did some more tests. and the latest issue #5702 related to structure ids in the original issue (first post in this thread) however is still open, even after integrating #5761. when trying to save a numeric value ( |
@jaro-io Have you tested it with the |
@lukasbestle i manually added all the changes from #5761 to my |
description
i have a
select
field which queries astructure
field from another page. this works fine. because we don’t have structure object uuids yet, it only saves the regular id (= index) of the structure object in the content txt file. but that’s fine for me.now i want to manually update the select field value, without using the panel, but through code. but no matter what value i pass, it just doesn’t get saved.
the select field:
the update code:
if i set the field type to
multiselect
,text
or anything else, the value gets saved in the content txt file perfectly fine. but as soon as i useselect
, it stops working.if i switch the select field to the regular options with hard-coded values and then pass one of them, it does get saved as well. so i bet there is some internal validation which checks if the select option actually exists. but with dynamic queries it doesn’t work.
i don’t exactly know what the $validate attribute is for, but it is set to
false
by default. i thought having this off, would mean no validation is done on kirby’s side?expected behavior
the passed value will be saved in the content.txt file. simple as that.
your setup
kirby
3.9
🙏🏻 ✨
The text was updated successfully, but these errors were encountered: