You are here

function _webform_edit_component in Webform 7.3

Same name and namespace in other branches
  1. 6.3 webform.api.php \_webform_edit_component()
  2. 7.4 webform.api.php \_webform_edit_component()

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

Related topics

File

./webform.api.php, line 656
Sample hooks demonstrating usage in Webform.

Code

function _webform_edit_component($component) {
  $form = array();

  // Disabling the description if not wanted.
  $form['description'] = array();

  // Most options are stored in the "extra" array, which stores any settings
  // unique to a particular component type.
  $form['extra']['options'] = array(
    '#type' => 'textarea',
    '#title' => t('Options'),
    '#default_value' => $component['extra']['options'],
    '#description' => t('Key-value pairs may be entered separated by pipes. i.e. safe_key|Some readable option') . theme('webform_token_help'),
    '#cols' => 60,
    '#rows' => 5,
    '#weight' => -3,
    '#required' => TRUE,
  );
  return $form;
}