Jump to content

SelectOptions with integer values


Clarity
 Share

Recommended Posts

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

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.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...