You are here

function _webform_edit_email in Webform 7.3

Same name and namespace in other branches
  1. 5.2 components/email.inc \_webform_edit_email()
  2. 5 components/email.inc \_webform_edit_email()
  3. 6.3 components/email.inc \_webform_edit_email()
  4. 6.2 components/email.inc \_webform_edit_email()
  5. 7.4 components/email.inc \_webform_edit_email()

Implements _webform_edit_component().

File

components/email.inc, line 50
Webform module email component.

Code

function _webform_edit_email($component) {
  $form['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Default value'),
    '#default_value' => $component['value'],
    '#description' => t('The default value of the field.') . theme('webform_token_help'),
    '#size' => 60,
    '#maxlength' => 127,
    '#weight' => 0,
    '#attributes' => $component['value'] == '%useremail' && count(form_get_errors()) == 0 ? array(
      'disabled' => TRUE,
    ) : array(),
    '#id' => 'email-value',
  );
  $form['user_email'] = array(
    '#type' => 'checkbox',
    '#title' => t('User email as default'),
    '#default_value' => $component['value'] == '%useremail' ? 1 : 0,
    '#description' => t('Set the default value of this field to the user email, if he/she is logged in.'),
    '#attributes' => array(
      'onclick' => 'getElementById("email-value").value = (this.checked ? "%useremail" : ""); getElementById("email-value").disabled = this.checked;',
    ),
    '#weight' => 0,
    '#element_validate' => array(
      '_webform_edit_email_validate',
    ),
  );
  $form['display']['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#default_value' => $component['extra']['width'],
    '#description' => t('Width of the textfield.') . ' ' . t('Leaving blank will use the default size.'),
    '#size' => 5,
    '#maxlength' => 10,
    '#parents' => array(
      'extra',
      'width',
    ),
  );
  $form['display']['disabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disabled'),
    '#return_value' => 1,
    '#description' => t('Make this field non-editable. Useful for setting an unchangeable default value.'),
    '#weight' => 11,
    '#default_value' => $component['extra']['disabled'],
    '#parents' => array(
      'extra',
      'disabled',
    ),
  );
  $form['validation']['unique'] = array(
    '#type' => 'checkbox',
    '#title' => t('Unique'),
    '#return_value' => 1,
    '#description' => t('Check that all entered values for this field are unique. The same value is not allowed to be used twice.'),
    '#weight' => 1,
    '#default_value' => $component['extra']['unique'],
    '#parents' => array(
      'extra',
      'unique',
    ),
  );
  return $form;
}