How to check if the value (not the field type) is an integer?

Options

I know about the "is_int" filter, however, the "is_int" filter checks if the field type is an integer, not the actual value.

I have my field type set to decimal because it stores both decimals and/or integers. As a result, I have no way of checking if the value itself is an integer or not because the "is_int" function always returns "false"

Tagged:

Best Answer

  • Nathan
    Nathan Member
    Answer ✓
    Options

    Possible solution: Create a new variable that is equal to the value you want to check and add the filter "to_int". Then do an if conditional to check if the values are the same - if they are the same then you know your original number is an integer, if they are not the same then you know your original number is a decimal.