function phone_textfield_process in Phone 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 'phone_textfield_process'
- phone_elements in ./
phone.module - Implementation of FAPI hook_elements().
File
- ./
phone.module, line 824 - Defines phone number fields for CCK. Provide some verifications on the phone numbers
Code
function phone_textfield_process($element, $edit, $form_state, $form) {
$field = $form['#field_info'][$element['#field_name']];
$field_key = $element['#columns'][0];
$delta = $element['#delta'];
$element[$field_key] = array(
'#type' => 'textfield',
'#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
'#size' => !empty($field['widget']['size']) ? $field['widget']['size'] : 60,
'#autocomplete_path' => FALSE,
// 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' => 'phone-field-textfield',
),
'#size' => 17,
'#maxlength' => 20,
);
if (!empty($field['max_length'])) {
// TODO Appears to be a non-existent property name.
$element[$field_key]['#maxlength'] = $field['max_length'];
}
if (!empty($field['text_processing'])) {
$filter_key = $element['#columns'][1];
$format = isset($element['#value'][$filter_key]) ? $element['#value'][$filter_key] : FILTER_FORMAT_DEFAULT;
$parents = array_merge($element['#parents'], array(
$filter_key,
));
$element[$filter_key] = filter_form($format, 1, $parents);
}
// 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;
}