You are here

function phone_field_widget_settings_form in Phone 7.2

Implements hook_field_widget_settings_form().

File

./phone.module, line 845
The phone module lets administrators use a phone number field type.

Code

function phone_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $defaults = field_info_widget_settings($widget['type']);
  $settings = array_merge($defaults, $widget['settings']);
  $form['country_code_position'] = array(
    '#type' => 'radios',
    '#title' => t('Country code position'),
    '#options' => array(
      'before' => t('Before phone number'),
      'after' => t('After phone number'),
    ),
    '#default_value' => $settings['country_code_position'],
    '#description' => t('Select the position of the country code selection field relative to the phone number text field.'),
    '#states' => array(
      'visible' => array(
        ':input[name="instance[settings][enable_country]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['number_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum size of a phone field'),
    '#default_value' => $settings['number_size'],
    '#element_validate' => array(
      '_element_validate_integer_positive',
    ),
    '#required' => TRUE,
    '#description' => t('International numbers are a maximum of 15 digits with additional country code. Default is %length.', array(
      '%length' => $defaults['number_size'],
    )),
    '#weight' => -2.8,
  );
  $form['extension_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Maxium size of extension field'),
    '#default_value' => $settings['extension_size'],
    '#element_validate' => array(
      '_element_validate_integer_positive',
    ),
    '#description' => t('This controls the maximum amount of data that can be stored in an extension field.'),
    '#states' => array(
      'visible' => array(
        ':input[name="instance[settings][enable_extension]"]' => array(
          'checked' => TRUE,
        ),
      ),
      'required' => array(
        ':input[name="instance[settings][enable_extension]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
    '#weight' => -2.4,
  );
  $form['numbertype_allowed_values_position'] = array(
    '#type' => 'radios',
    '#title' => t('Number type allowed values position'),
    '#options' => array(
      'before' => t('Before phone number'),
      'after' => t('After phone number'),
    ),
    '#default_value' => $settings['numbertype_allowed_values_position'],
    '#description' => t('Select the position of the number type field relative to the phone number text field.'),
    '#states' => array(
      'visible' => array(
        ':input[name="field[settings][enable_numbertype]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
    '#weight' => -2,
  );
  $form['use_tel_input'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use input type=tel for editing'),
    '#default_value' => $settings['use_tel_input'],
    '#weight' => -1,
  );
  $form['label_position'] = array(
    '#type' => 'radios',
    '#title' => t('Position of phone part labels'),
    '#description' => t('The location of phone part labels, like "Number", "Country", "Extension", or "Type". "Before" displays the label as titles before each phone part. "Above" displays the label as titles above each phone part. "None" does not label any of the phone parts. Theme functions like "phone_part_label_number", "phone_part_label_country", "phone_part_label_extension", and "phone_part_label_type" control label text.'),
    '#options' => array(
      'before' => t('Before'),
      'above' => t('Above'),
      'none' => t('None'),
    ),
    '#default_value' => $settings['label_position'],
  );
  return $form;
}