function phonefield_field_process in Phone Field 7
Processes the phonefield type element before displaying the field.
Build the form element. When creating a form using FAPI #process, note that $element['#value'] is already set.
The $fields array is in $complete_form['#field_info'][$element['#field_name']].
1 string reference to 'phonefield_field_process'
- phonefield_element_info in ./
phonefield.module - Implements hook_element_info().
File
- ./
phonefield.module, line 312 - Hooks for a module that defines a simple phone number field type.
Code
function phonefield_field_process($element, $form_state, $complete_form) {
$instance = field_widget_instance($element, $form_state);
$settings = $instance['settings'];
$element['phonenumber'] = array(
'#type' => 'textfield',
'#maxlength' => 63,
'#title' => t('Phone number'),
'#description' => t('A free-format phone number.'),
'#required' => FALSE,
'#default_value' => isset($element['#value']['phonenumber']) ? $element['#value']['phonenumber'] : NULL,
);
if (in_array($settings['linkstate'], array(
'optional',
))) {
$element['linklabel'] = array(
'#type' => 'textfield',
'#maxlength' => 63,
'#title' => t('Text'),
'#description' => t('Anchor text or link label.'),
'#required' => FALSE,
'#default_value' => isset($element['#value']['linklabel']) ? $element['#value']['linklabel'] : NULL,
);
}
return $element;
}