1 form_example_elements.inc form_example_phonenumber_combined_value(&$element, $input = FALSE, $form_state = NULL)

Value callback for form_example_phonenumber_combined.

Builds the current combined value of the phone number only when the form builder is not processing the input.

Parameters

array $element: Form element.

array $input: Input.

array $form_state: Form state.

Return value

array: The modified element.

File

modules/examples/form_example/form_example_elements.inc, line 185
This is an example demonstrating how a module can define custom form and render elements.

Code

function form_example_phonenumber_combined_value(&$element, $input = FALSE, $form_state = NULL) {
  if (!$form_state['process_input']) {
    $matches = array();
    $match = preg_match('/^(\d{3})(\d{3})(\d{4})$/', $element['#default_value'], $matches);
    if ($match) {
      // Get rid of the "all match" element.
      array_shift($matches);
      list($element['areacode'], $element['prefix'], $element['extension']) = $matches;
    }
  }
  return $element;
}