function _partial_date_element_process in Partial Date 7
Roll out a single date element.
1 call to _partial_date_element_process()
- partial_date_element_process in ./
partial_date.module - Roll out a single date element.
File
- ./
partial_date.admin.inc, line 1186 - Less freq. functions for field administration.
Code
function _partial_date_element_process($element) {
$granularity = $element['#granularity'];
$estimates = $element['#estimates'];
$options = $element['#estimate_options'];
$increments = empty($element['#increments']) ? array() : $element['#increments'];
$increments += array(
'second' => 1,
'minute' => 1,
);
$blank_option = array(
'' => t('N/A'),
);
foreach (partial_date_components() as $key => $label) {
if (!empty($estimates[$key]) && !empty($options[$key])) {
$estimate_label = t('@component estimate', array(
'@component' => $label,
));
$element[$key . '_estimate'] = array(
'#type' => 'select',
'#title' => $estimate_label,
'#description' => $estimate_label,
'#title_display' => 'invisible',
'#value' => empty($element['#value'][$key . '_estimate']) ? '' : $element['#value'][$key . '_estimate'],
'#attributes' => $element['#attributes'],
'#options' => $blank_option + $options[$key],
);
}
if (!empty($granularity[$key])) {
if ($key == 'year') {
$element[$key] = array(
'#type' => 'textfield',
'#title' => $label,
'#description' => $label,
'#title_display' => 'invisible',
'#value' => empty($element['#value'][$key]) ? '' : $element['#value'][$key],
'#attributes' => $element['#attributes'],
'#required' => TRUE,
);
$element[$key]['#attributes']['size'] = 5;
}
else {
$inc = empty($increments[$key]) ? 1 : $increments[$key];
$element[$key] = array(
'#type' => 'select',
'#title' => $label,
'#description' => $label,
'#title_display' => 'invisible',
'#value' => isset($element['#value'][$key]) && strlen($element['#value'][$key]) ? $element['#value'][$key] : '',
'#attributes' => $element['#attributes'],
'#options' => partial_date_granularity_field_options($key, $blank_option, $inc),
);
}
}
}
$css = $element['#component_styles'];
foreach (element_children($element) as $child) {
if ($element[$child]['#type'] != 'value') {
$element[$child]['#prefix'] = '<div class="partial-date-' . str_replace('_', '-', $child) . '" style="' . $css . '">';
$element[$child]['#suffix'] = '</div>';
}
}
return $element;
}