You are here

function double_field_field_widget_settings_form in Double Field 7

Same name and namespace in other branches
  1. 7.2 double_field.module \double_field_field_widget_settings_form()

Implements hook_field_widget_settings_form().

File

./double_field.module, line 113
Defines double text field type.

Code

function double_field_field_widget_settings_form($field, $instance) {
  $settings = $instance['widget']['settings'];
  $form['inline'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display as inline element'),
    '#default_value' => $settings['inline'],
  );
  foreach (array(
    'first',
    'second',
  ) as $subfield) {
    $form[$subfield] = array(
      '#title' => t('@subfield subfield', array(
        '@subfield' => t($subfield),
      )),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form[$subfield]['required'] = array(
      '#type' => 'checkbox',
      '#title' => t('Required'),
      '#default_value' => $settings[$subfield]['required'],
      '#states' => array(
        'visible' => array(
          ':input[name="instance[required]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
    $form[$subfield]['size'] = array(
      '#type' => 'textfield',
      '#title' => t('Size'),
      '#default_value' => $settings[$subfield]['size'],
      '#element_validate' => array(
        '_element_validate_integer_positive',
      ),
      '#size' => 3,
    );
    $form[$subfield]['prefix'] = array(
      '#type' => 'textfield',
      '#title' => t('Prefix'),
      '#maxlength' => 50,
      '#default_value' => $settings[$subfield]['prefix'],
    );
    $form[$subfield]['suffix'] = array(
      '#type' => 'textfield',
      '#title' => t('Suffix'),
      '#maxlength' => 50,
      '#default_value' => $settings[$subfield]['suffix'],
    );
  }
  return $form;
}