Clarity Posted February 20, 2023 Share Posted February 20, 2023 Hello everyone! I have SelectOptions field which is supposed to contain integer values for the purpose of using them in selector and compare with other integer values like this: $pages->find('select_options.value>' . $integer) For example, I have SelectOptions like this: 1=5|title1 2=20|title2 3=40|title3 4=60|title4 5=85|title5 So I get that values are being strings and I can't compare them with some other value. Can you please tell me how to handle it if it is possible with SelectOptions? Link to comment Share on other sites More sharing options...
Robin S Posted February 20, 2023 Share Posted February 20, 2023 I suggest replacing your Select Options field with a Page Reference field. The template for the page items would contain an integer field. My experience is that when deciding between a Select Options field and Page Reference field, the page field is the one you want 90% of the time because pages are so much more powerful and flexible than select options. Even if the needs are simple to begin with, a page field is more future-proof. The Page Field Select Creator module makes the field setup a breeze. 1 1 Link to comment Share on other sites More sharing options...
DV-JF Posted February 20, 2023 Share Posted February 20, 2023 inval($integer) or (int)$integer Just use the code above ? 2 Link to comment Share on other sites More sharing options...
Clarity Posted February 21, 2023 Author Share Posted February 21, 2023 15 hours ago, Robin S said: I suggest replacing your Select Options field with a Page Reference field. The template for the page items would contain an integer field. My experience is that when deciding between a Select Options field and Page Reference field, the page field is the one you want 90% of the time because pages are so much more powerful and flexible than select options. Even if the needs are simple to begin with, a page field is more future-proof. The Page Field Select Creator module makes the field setup a breeze. Thank you, it indeed works. 15 hours ago, DV-JF said: inval($integer) or (int)$integer Just use the code above ? Thank you, but the select option values are still being stored as a string and $integer is already an int and doesn't need conversion. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now