Community Documentation

example_element_expand

5 example_element.module example_element_expand($element)

Our process callback to expand the control.

File

developer/examples/example_element.module, line 64
This is an example demonstrating how a module can define custom form elements.

Code

<?php
function example_element_expand($element) {
  $element['#tree'] = TRUE;

  if (!isset($element['#value'])) {
    $element['#value'] = array(
      'areacode' => '',
      'number' => '',
      'extension' => '',
    );
  }

  $element['areacode'] = array(
    '#type' => 'textfield', 
    '#size' => 3, 
    '#maxlength' => 3, 
    '#value' => $element['#value']['areacode'], 
    '#prefix' => '(', 
    '#suffix' => ')',
  );
  $element['number'] =  array(
    '#type' => 'textfield', 
    '#size' => 8, 
    '#maxlength' => 8, 
    '#required' => TRUE, 
    '#value' => $element['#value']['number'],
  );
  $element['extension'] =  array(
    '#type' => 'textfield', 
    '#size' => 10, 
    '#maxlength' => 10, 
    '#prefix' => t('ext'), 
    '#value' => $element['#value']['extension'],
  );

  return $element;
}
?>
Login or register to post comments