function commerce_file_limit_integer_element_process in Commerce File 7
FAPI process callback for limit textfield element type.
1 string reference to 'commerce_file_limit_integer_element_process'
- commerce_file_element_info in includes/
commerce_file.elements.inc - Implements hook_element_info().
File
- includes/
commerce_file.elements.inc, line 83 - Commerce File form elements
Code
function commerce_file_limit_integer_element_process($element, &$form_state) {
// Put the child elements in a container div.
$element['#prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : '';
$element['#prefix'] = '<div class="commerce-file-limit-integer-element commerce-file-limit-element">' . $element['#prefix'];
unset($element['#field_prefix']);
// move description to the top
if (isset($element['#description'])) {
$element['description'] = array(
'#markup' => '<div class="description">' . $element['#description'] . '</div>',
'#weight' => -10,
);
unset($element['#description']);
}
// close container
$element['#suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : '';
$element['#suffix'] .= '</div>';
unset($element['#field_suffix']);
// attach css
$element['#attached']['css'][] = drupal_get_path('module', 'commerce_file') . '/css/commerce_file.forms.css';
// build limit mode and value
$element['#mode_options'] = _commerce_file_limit_element_get_mode_options($element);
$defaults = _commerce_file_limit_element_get_defaults($element);
$element['mode'] = array(
'#type' => 'radios',
'#options' => $element['#mode_options'],
'#default_value' => $defaults['mode'],
'#attributes' => array(
'class' => array(
'commerce-file-limit-element-mode',
),
),
);
$element['value'] = array(
'#type' => 'textfield',
'#size' => 10,
'#default_value' => $defaults['value'],
'#attributes' => array(
'class' => array(
'commerce-file-limit-element-value',
),
),
'#states' => array(
'visible' => array(
':input[name="' . $element['#name'] . '[mode]"]' => array(
'value' => 'value',
),
),
),
);
return $element;
}