public function UcAddressesDateFieldHandler::getFormField in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 handlers/uc_addresses.handlers.inc \UcAddressesDateFieldHandler::getFormField()
Implements UcAddressesFieldHandler::getFormField().
Overrides UcAddressesFieldHandler::getFormField
File
- handlers/
uc_addresses.handlers.inc, line 219 - Field handlers for Ubercart Addresses address fields:
Class
- UcAddressesDateFieldHandler
- Class for the created/modified field.
Code
public function getFormField($form, $form_values) {
$fieldName = $this
->getFieldName();
$fieldValue = $this
->getAddress()
->getField($fieldName);
$default = isset($form_values[$fieldName]) ? $form_values[$fieldName] : $fieldValue;
if (is_numeric($default)) {
$default = array(
'hour' => date('H', $default),
'minute' => date('i', $default),
'second' => date('s', $default),
'month' => date('n', $default),
'day' => date('j', $default),
'year' => date('Y', $default),
);
}
return array(
$fieldName => array(
'#type' => 'date',
'#title' => $this
->getFieldTitle(),
'#default_value' => $default,
'#required' => $this
->isFieldRequired(),
),
);
}