function isbn_field_process in ISBN Field 6
Process an individual element.
Build the form element. When creating a form using FAPI #process, note that $element['#value'] is already set.
The $fields array is in $form['#field_info'][$element['#field_name']].
1 string reference to 'isbn_field_process'
- isbn_elements in ./
isbn.module - Implementation of FAPI hook_elements().
File
- ./
isbn.module, line 475 - Defines ISBN field types.
Code
function isbn_field_process($element, $edit, $form_state, $form) {
$field = $form['#field_info'][$element['#field_name']];
$field_key = $element['#columns'][0];
//Add JS for validation
if ($field['isbn_validation'] == ISBN_JS_VALIDATION) {
$js_validate_class = 'isbn-validate';
isbn_dynamic_validation();
}
$element[$field_key] = array(
'#type' => 'textfield',
'#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
'#weight' => 0,
// The following values were set by the content module and need
// to be passed down to the nested element.
'#title' => $element['#title'],
'#description' => $element['#description'],
'#required' => $element['#required'],
'#field_name' => $element['#field_name'],
'#type_name' => $element['#type_name'],
'#delta' => $element['#delta'],
'#columns' => $element['#columns'],
'#attributes' => array(
'class' => $js_validate_class,
'isbn-format' => $field['isbn_format'],
),
);
// Used so that hook_field('validate') knows where to flag an error.
$element['_error_element'] = array(
'#type' => 'value',
'#value' => implode('][', array_merge($element['#parents'], array(
$field_key,
))),
);
return $element;
}