You are here

function _webform_edit_component in Webform 7.4

Same name and namespace in other branches
  1. 6.3 webform.api.php \_webform_edit_component()
  2. 7.3 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

array $component: A Webform component array.

array $form: The form array.

array $form_state: The form state array.

Return value

array Return $form with whatever changes are desired.

Related topics

File

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

Code

function _webform_edit_component(array $component, array $form, array $form_state) {

  // Disabling the description if not wanted.
  $form['description']['#access'] = FALSE;

  // 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;
}