function date_popup_element_process in Date 7.3
Same name and namespace in other branches
- 7 date_popup/date_popup.module \date_popup_element_process()
- 7.2 date_popup/date_popup.module \date_popup_element_process()
Javascript popup element processing.
Add popup attributes to $element.
1 string reference to 'date_popup_element_process'
- date_popup_element_info in date_popup/
date_popup.module - Implements hook_element_info().
File
- date_popup/
date_popup.module, line 304 - A module to enable jQuery calendar and time entry popups.
Code
function date_popup_element_process($element, &$form_state, $form) {
if (date_hidden_element($element)) {
return $element;
}
date_popup_add();
module_load_include('inc', 'date_api', 'date_api_elements');
$element['#tree'] = TRUE;
$element['#theme_wrappers'] = array(
'date_popup',
);
if (!empty($element['#ajax'])) {
$element['#ajax'] += array(
'trigger_as' => array(
'name' => $element['#name'],
),
'event' => 'change',
);
}
$element['date'] = date_popup_process_date_part($element);
$element['time'] = date_popup_process_time_part($element);
// Make changes if instance is set to be rendered as a regular field.
if (!empty($element['#instance']['widget']['settings']['no_fieldset']) && $element['#field']['cardinality'] == 1) {
if (!empty($element['date']) && empty($element['time'])) {
$element['date']['#title'] = check_plain($element['#instance']['label']);
$element['date']['#required'] = $element['#required'];
}
elseif (empty($element['date']) && !empty($element['time'])) {
$element['time']['#title'] = check_plain($element['#instance']['label']);
$element['time']['#required'] = $element['#required'];
}
}
if (isset($element['#element_validate'])) {
array_push($element['#element_validate'], 'date_popup_validate');
}
else {
$element['#element_validate'] = array(
'date_popup_validate',
);
}
$context = array(
'form' => $form,
);
// Trigger hook_date_popup_process_alter().
drupal_alter('date_popup_process', $element, $form_state, $context);
return $element;
}