Chris Johnson
2004-10-21 22:55:12 UTC
I have added an additional form element function to my local common.inc to
handle dates for my sites. Is there any interest in generalizing /
refactoring it to be included into Drupal? If so, I'll do the work with a
little help and guidance from you all.
Here's what it currently looks like:
[?php
function form_date($title, $name, $value, $description = NULL, $attributes =
NULL, $required = FALSE) {
$classname = _form_get_class('form-date', $required,
_form_get_error($name));
$monthval = check_form($value['month']);
$dayval = check_form($value['day']);
$yearval = check_form($value['year']);
$monthname = $name . 'mm';
$dayname = $name . 'dd';
$yearname = $name . 'yy';
$html = <<<EOT
<input type="text" maxlength="2" class="$classname" name="edit[$monthname]"
id="edit-$monthname" size="2" value="$monthval" />
<span class="dateslash">/</span>
<input type="text" maxlength="2" class="$classname" name="edit[$dayname]"
id="edit-$dayname" size="2" value="$dayval" />
<span class="dateslash">/</span>
<input type="text" maxlength="4" class="$classname" name="edit[$yearname]"
id="edit-$yearname" size="4" value="$yearval" />
EOT;
return theme('form_element', $title, $html, $description, 'edit-'. $name,
$required, _form_get_error($name));
}
?]
--
Chris Johnson
handle dates for my sites. Is there any interest in generalizing /
refactoring it to be included into Drupal? If so, I'll do the work with a
little help and guidance from you all.
Here's what it currently looks like:
[?php
function form_date($title, $name, $value, $description = NULL, $attributes =
NULL, $required = FALSE) {
$classname = _form_get_class('form-date', $required,
_form_get_error($name));
$monthval = check_form($value['month']);
$dayval = check_form($value['day']);
$yearval = check_form($value['year']);
$monthname = $name . 'mm';
$dayname = $name . 'dd';
$yearname = $name . 'yy';
$html = <<<EOT
<input type="text" maxlength="2" class="$classname" name="edit[$monthname]"
id="edit-$monthname" size="2" value="$monthval" />
<span class="dateslash">/</span>
<input type="text" maxlength="2" class="$classname" name="edit[$dayname]"
id="edit-$dayname" size="2" value="$dayval" />
<span class="dateslash">/</span>
<input type="text" maxlength="4" class="$classname" name="edit[$yearname]"
id="edit-$yearname" size="4" value="$yearval" />
EOT;
return theme('form_element', $title, $html, $description, 'edit-'. $name,
$required, _form_get_error($name));
}
?]
--
Chris Johnson