I need a field allowing either a numeric value or "unlimited".

The Unlimited Number module is exactly what I want, but it's D8-only.

Is there a way to do the same thing in D7?

  • I am not able to understand. From your question title it looks you need unlimited field, if so, kindly check Field collection module or Field Group module, when you set up, it has a option to chose number of field or chose unlimited fields. May be this may help.
    – CodeNext
    Feb 20, 2016 at 20:49
  • The OP is talking about the Unlimited number module, which allows the users to select a number from a option list or a special number with a specific meaning. It's not about entering multiple entries for the same field.
    – apaderno
    Feb 20, 2016 at 22:12

1 Answer 1


To implement a field allowing either a numeric value or "unlimited" in D7, you can define such field using the desired widget (like a textfield maybe?). And then use the Rules module to validate the actual data that is entered before the entity (like a node or user where you use that field?) is saved (created or updated).

Some more details about the validation part of such rules to be created:

  1. Add the appropriate validations you want within the Rules Conditions.
  2. You may want to specify multiple conditions and combine them with an "OR", eg to validate that the value entered is either the string "unlimited", or a digit equal to "0", "1", "2", "3" or "4".
  3. If you have lots of allowed digits (say dozens), just use an appropriate regular expression (instead of a loooong list of digits).

Have a look at my answer to "How to make the permissions of a module more granular?", which you can use as examples of what might be needed to implement Rules conditions as in bullets "2." or "3." above.

Of course you'd also have to pick the most appropriate Rules Event for this rule to be triggered. But there are quite a few, straight forward, events you can pick from (depending on where exactly you want to use this field), just to mention a few:

  • Before inserting a new node (optionally limited to content type ABC). E.g. if your field is used to "Store the maximum speed on highways in country X".
  • Before saving an update to a user profile. E.g. if your field is used to "Store the duration (in days, months or years) of some type of membership subscription".

And your Rules Action is probably just a simple "Drupal set message". Though I can think of honeypot-scenarios where some specific values that got selected could result in a rules action like "block this user".

If you want even more granularity, you might also want to have a look at Conditional Rules, which allows for using "Rules Conditions" within "Rules Actions". Refer to my answer to "How to prevent a node being saved when using the Rules module?" for an illustration of using this module.

  • Pierre, thanks for the detailed answer. I haven't used Rules yet, but I'll certainly give it a look. I've since thought of a different way I could get what I want: with conditional fields. I'll report back either way, so that other D7 users can find a solution.
    – UTAN_dev
    Feb 27, 2016 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.