You are here

function _webform_edit_phone in Webform Phone Number 7.2

Same name and namespace in other branches
  1. 7 webform_phone.components.inc \_webform_edit_phone()

Generate the form for editing a component. Create a set of form elements to be displayed on the form for editing this component. Use care naming the form items, as this correlates directly to the database schema. The component "Name" and "Description" fields are added to every component type and are not necessary to specify here (although they may be overridden if desired).

Parameters

$component: A Webform component array.

Return value

An array of form items to be displayed on the edit component page

File

./webform_phone.components.inc, line 96
Webform Component information for a phone number field type

Code

function _webform_edit_phone($component) {
  require_once PHONE_MODULE_PATH . '/phone.module';

  //not really needed, since .modules are always in the namespace
  $field_widget_instance = array(
    'widget' => array(
      'type' => 'phone',
      'settings' => $component['extra']['widget_settings'],
    ),
  );
  $field_instance = array(
    'type' => 'phone',
    'settings' => $component['extra']['field_settings'],
  );
  $display_instance = array(
    'display' => array(
      'webform' => array(
        'settings' => $component['extra']['display_settings'],
      ),
    ),
  );
  $phone_widget_settings_form = phone_field_widget_settings_form(array(), $field_widget_instance);
  $phone_field_settings_form = phone_field_settings_form($field_instance, NULL, FALSE);
  $fake_form_state = array();
  $phone_display_settings_form = phone_field_formatter_settings_form(NULL, $display_instance, 'webform', NULL, $fake_form_state);

  //Copy the format used by the field portion of the Phone module...so their 'state' attrs will still work
  $form = array(
    'instance' => array(
      '#type' => 'fieldset',
      '#collapsible' => FALSE,
      '#title' => t('Phone Settings'),
      'widget' => array(
        'settings' => $phone_widget_settings_form,
      ),
      'field' => array(
        '#type' => 'fieldset',
        '#collapsible' => FALSE,
        '#title' => t('Widget Settings'),
        'settings' => $phone_field_settings_form,
      ),
      'display' => array(
        '#type' => 'fieldset',
        '#collapsible' => FALSE,
        '#title' => t('Display Settings'),
        '#description' => t('Settings for how this field\'s value will be rendered.'),
        'settings' => $phone_display_settings_form,
      ),
    ),
  );
  return $form;
}