It'd be handy to have a date component type that only requires entering month and year, or an option on the date component that lets you just use month and year.
I worked up a cheezy fix by removing the lines below from the _webform_render_date function, near the end. These are the 6 lines commented out below:
$formItem['month'] = array(
'#type' => 'select',
'#default_value' => $month,
'#options' => $months,
'#validate' => array ('webform_validate_date' => array ('month',$component['name'],$component['mandatory']) ),
);
// $formItem['day'] = array(
// '#type' => 'select',
// '#default_value' => $day,
// '#options' => $days,
// '#validate' => array ('webform_validate_date' => array ('day',$component['name'],$component['mandatory']) ),
// );
$formItem['year'] = array(
'#type' => 'textfield',
'#default_value' => $year,
'#maxlength' => 4,
'#size' => 4,
'#validate' => array ('webform_validate_date' => array ('year',$component['name'],$component['mandatory']) ),
);
This simply removes the day part of the date from the input form -- and there's probably a much better way to adapt this component. It appears to work fine as a substitute for the date component; my guess is that if you wanted to use both this and the shipped date component, you'd need to change the function names to avoid conflicts.
Comments
Comment #1
BioALIEN commentedThanks for the info. I think the proper way to do this would be to show all the options:
Year Month Day Hour Minute Second
And let the user filter what type to show or how many levels - exactly how the CCK module folks have done.
Comment #2
dquakenbush commentedDid this go anywhere?
Comment #3
dquakenbush commentedHere's a fix that puts a checkbox in the form assembly screen...
I couldn't get it to work without any day (would drop the date entirely on the e-mail), so the check box hides the day field and forces the day to "01", which shows up in the e-mail... works for what we're doing, and hopefully will help you until a proper patch can be created by a real programmer...
All changes are in date.inc
Near line 38 I added this just before the "return $edit_fields;" :
Then in the render area I replaced the [day] code with this:
No guarantees this won't break something somewhere, but it seems to work for me. Good luck :-)
Comment #4
quicksketchIf this functionality is ever added to webform it'll come as an enhancement to the existing date component. In Drupal 6, we may be able to reuse the date.module configuration (which is quite extensive). Let's open a new issue for this functionality as a part of the date component if desired.