How do I...

Events happening in the community are now at Drupal community events on www.drupal.org.
Maestro232's picture

I would like to modify the "Time" field type in a webform (from webform module) such that the minutes selector has only ":00" and ":30" as values. I'd only like this change to apply to a single form. Is this possible?

Comments

One possibility

druderman's picture

Looks like there is a patch you can try.
http://drupal.org/node/434584

This is a D7 patch...

Maestro232's picture

Thanks for the heads up. This appears to be a D7 patch and we're on D6. Any ideas?

As suggested in the link

druderman's picture

As suggested in the link above, a similar patch could be applied to D6.

An expedient fix is to edit this file:
/modules/webform/components/time.inc

and change this:
for ($i = 0; $i <= 59; $i++) $minutes[$i] = $i < 10 ? "0$i" : $i;
to this:
for ($i = 0; $i <= 59;) { $minutes[$i] = $i < 10 ? "0$i" : $i; $i += 30; }

It seems....

Maestro232's picture

It seems to me that the patch gave the user flexibilty in adjusting the increments by element, but the change above would force that change on any time element in any webform I make, correct?

True enough...

druderman's picture

Yup, this (same result as version above) would limit all webform times to 00 or 30 no matter what.

for ($i = 0; $i <= 59; $i+=30) $minutes[$i] = $i < 10 ? "0$i" : $i;

well..

Maestro232's picture

Well, it's not the most flexible solution, but I hard-coded it to 15 minute increments instead of 30 and I think that will be reasonable for any forms I need to make on this particular domain. Thanks for the help.

If you were up to it and had

druderman's picture

If you were up to it and had the time (and we rarely do) you could adapt that D7 patch for D6 and put it up at drupal.org.

UMass Amherst User's Group

Group categories

Tags

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: