5

I would like to add an integer/decimal/float field to a content type where users can define ranges for these numbers as two separate fields.
Like when adding a Date field, and being able to add an end date as a separate field with a little checkbox:

Date field ranges (So the output will be like this: 2011 - 2012.)

Use case: users would like to define approximate numbers, they don't know data exactly, for example:

Stream bed's average depth: 0.3 m - 1 m
Stream bed's average width: 1 m - 2 m

(m would only be a suffix) etc.

2
  • If you're using Drupal 6 there's the range and measured value field modules...I haven't seen anything similar for Drupal 7
    – Clive
    Sep 29 '12 at 21:15
  • @Clive: oh, sorry (and thanks), I forgot to mention I'm using D7... added it to tags. I'm sorry to hear that there are no modules to do that (or we just haven't found any of them yet).
    – Sk8erPeter
    Sep 29 '12 at 21:21
3

I needed the same functionality for a project I am working on.

I have created a sandbox project http://drupal.org/sandbox/thepearson/1842424 which I'll be working on hopefully releasing as contrib. I still need to do some more testing, tidy up and documentation.

Obviously it's in sandbox so, use at your own risk. Currently supports int and float. Supports defining min and max limits on both start and end values along with prefix, suffix and range indicator. ie:

[prefix] [min] [indicator] [max] [suffix]
[$ ]     [123] [<----->]   [157] [per person]

alnum type is there but limit validation seems a bit buggy. I would recommend not using alnum until more testing is done.

It's also supports some hook_info/hook_info_alter functions for you to either define your own range datatypes, or change the existing ones. Look at the sub-module range_integer to see how it's done.

If you find any bugs please raise bug reports at drupal.org.

12
  • wow, thank you very much! This is a really good initiative, I just tried it, and it seems like a really good start. I will provide infos about the bugs I experienced and suggestions I found out when testing. ;) Thanks again! Voted up and accepted!
    – Sk8erPeter
    Nov 21 '12 at 16:44
  • How do I install and use it? Sorry but am novice. Nov 21 '12 at 17:56
  • @Raj - take look at this which should help as a git/sandbox primer. Clone the repo into a site module folder and then enable it via your modules screen. If Fields UI module is turned on you can then add a "Range" field to any content type.
    – thepearson
    Nov 21 '12 at 22:23
  • @Raj: on Windows, you should install GitHub for Windows, start Git Shell (from the Start menu), and run git clone http://git.drupal.org/sandbox/thepearson/1842424.git ranges. After that, you can copy the downloaded ranges folder to your sites/all/modules directory.
    – Sk8erPeter
    Nov 21 '12 at 23:52
  • I am aware of and use Git, am novice at Drupal though ;) I will place the same in modules folder of site. When are you planning for a full featured release of the same? Thanks for this feature! Actually I cant believe that there is no support for range type of fields! Nov 22 '12 at 5:26
2

There is also Taran2l's Range field module, which already passed module review and is now on its way on taking over Range project (which is stuck on 6.x version and seems to be abandoned). It would be nice if @thepearson collaborated with the author of this module.

UPD: Taran2l is now official owner of the Range project.

1
  • +1 for the suggestion, thanks! I agree that it would be great to merge the two modules, and for the two developers to help each other's efforts.
    – Sk8erPeter
    Feb 9 '13 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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