You are here

function _webform_edit_email in Webform 7.4

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.3 components/email.inc \_webform_edit_email()

Implements _webform_edit_component().

File

components/email.inc, line 55
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'] == '[current-user:mail]' && !form_get_errors() ? array(
      'disabled' => TRUE,
    ) : array(),
    '#id' => 'email-value',
  );
  $form['user_email'] = array(
    '#type' => 'checkbox',
    '#title' => t('User email as default'),
    '#default_value' => $component['value'] == '[current-user:mail]' ? 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 ? "[current-user:mail]" : ""); getElementById("email-value").disabled = this.checked;',
    ),
    '#weight' => 0,
    '#element_validate' => array(
      '_webform_edit_email_validate',
    ),
  );
  $form['extra']['multiple'] = array(
    '#type' => 'checkbox',
    '#title' => t('Multiple'),
    '#default_value' => $component['extra']['multiple'],
    '#description' => t('Allow multiple e-mail addresses, separated by commas.'),
    '#weight' => 0,
  );
  if (webform_variable_get('webform_email_address_format') == 'long') {
    $form['extra']['format'] = array(
      '#type' => 'radios',
      '#title' => t('Format'),
      '#options' => array(
        'long' => t('Allow long format: "Example Name" <name@example.com>'),
        'short' => t('Short format only: name@example.com'),
      ),
      '#default_value' => $component['extra']['format'],
      '#description' => t('Not all servers support the "long" format.'),
    );
  }
  $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']['placeholder'] = array(
    '#type' => 'textfield',
    '#title' => t('Placeholder'),
    '#default_value' => $component['extra']['placeholder'],
    '#description' => t('The placeholder will be shown in the field until the user starts entering a value.') . ' ' . t('Often used for example values, such as "john@example.com".'),
    '#parents' => array(
      'extra',
      'placeholder',
    ),
  );
  $form['display']['disabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disabled'),
    '#return_value' => 1,
    '#description' => t('Make this field non-editable. Useful for displaying default value. Changeable via JavaScript or developer tools.'),
    '#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;
}