Hi

I'm trying to create an 'Age' field that can store the age in months (up until 1 year) and then in years beyond that.

I had envisaged a textfield and a select list with Months/Years, and then some validation if the user enters more than 11 months. I then thought the value could be stored in single integer field in the database, in months. This is then always rendered as months below a year, otherwise years.

I suspect that the best way to do this is to write a module that provides a custom field called 'Age' with a custom widget. Unfortunately I'm not getting very far with this, mainly because there seems to be very little documentation on widgets for Drupal 6.

Is anyone able to point me in the right direction for some documentation or perhaps offer an alternative?

Thanks

Comments

MidGe48’s picture

Duration in Date/Time module may do the trick. It allows you to enter separately years and months (And day, hours, minutes, etc.). A bit of handling/coding may allow you to ignore the months if there is a value in the year field in the presentation layer.

www.ZuNOB.com

seddonym’s picture

Thanks - I found the Duration module (I don't think it's kept in Date/Time though) and it is close enough.

The only problem is that it doesn't seem to work with Views 2; not sortable or filterable. I might have to write a custom module.

Thanks for your help. It is a shame though that widgets for D6 are so underdocumented.