You are here

public function FlexiformElementField::configureForm in Flexiform 7

Overrides FlexiformElement::configureForm().

Overrides FlexiformElement::configureForm

1 call to FlexiformElementField::configureForm()
FlexiformElementField_taxonomy_term_reference::configureForm in includes/element/fields/taxonomy_term_reference.inc
Overrides FlexiformElement::configureForm().
1 method overrides FlexiformElementField::configureForm()
FlexiformElementField_taxonomy_term_reference::configureForm in includes/element/fields/taxonomy_term_reference.inc
Overrides FlexiformElement::configureForm().

File

includes/element/field.element.inc, line 254
Contains FlexiformElementField class.

Class

FlexiformElementField
Class for Field API elements.

Code

public function configureForm($form, &$form_state, $flexiform) {
  form_load_include($form_state, 'inc', 'field_ui', 'field_ui.admin');
  $instance = $this
    ->getInstance();
  $field = $this
    ->getField();
  $form = field_ui_field_edit_form($form, $form_state, $instance);

  // Invoke hook_form_alter() and hook_form_field_ui_field_edit_form_alter()

  /*$hooks = array('form');
    $hooks[] = 'form_field_ui_field_edit_form';
    $fake_form_id = 'field_ui_field_edit_form';
    drupal_alter($hooks, $form, $form_state, $fake_form_id);*/

  // If the default value behaviour is default, expose our better default
  // value form.
  if ($this
    ->checkWidgetBehavior()) {

    // Allow changes to the default values regardless of anything else thats
    // going on.
    $form['instance']['use_default_value_function'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use a Default Value Function'),
      '#default_value' => !empty($instance['default_value_function']),
    );
    $form['instance']['default_value_function'] = array(
      '#type' => 'textfield',
      '#title' => t('Default Value Function'),
      '#description' => t('If you wish to use a custom default value function, enter the name of it here. Reccommended for advanced users only.'),
      '#default_value' => isset($instance['default_value_function']) ? $instance['default_value_function'] : NULL,
      '#states' => array(
        'invisible' => array(
          ':input[name="instance[use_default_value_function]"]' => array(
            'checked' => FALSE,
          ),
        ),
      ),
    );
    $form['instance']['default_value_widget'] = field_ui_default_value_widget($this
      ->getField(), $instance, $form, $form_state);
    $form['instance']['default_value_widget']['#states'] = array(
      'visible' => array(
        ':input[name="instance[use_default_value_function]"]' => array(
          'checked' => FALSE,
        ),
      ),
    );
    $form['instance']['use_default_value_tokens'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use Tokens in Default Value'),
      '#default_value' => !empty($instance['use_default_value_tokens']),
      '#states' => array(
        'visible' => array(
          ':input[name="instance[use_default_value_function]"]' => array(
            'checked' => FALSE,
          ),
        ),
      ),
    );
    $form['instance']['contexts'] = array(
      '#title' => t('Substitutions'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#status' => array(
        'visible' => array(
          ':input[name="instance[use_default_value_tokens]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
    $form['instance']['contexts']['contexts'] = $this
      ->getCtoolsSubstitutionsList();
  }

  // Rename the boxes and discourage use of field settings.
  $form['instance']['#title'] = t('Form Settings');
  $form['instance']['#description'] = t('These settings will override default Field API settings for this field instance. Overrides will only apply to this flexiform.');
  $form['field'] = $this
    ->configureFieldSettingsForm($form, $form_state, $field, $instance);

  // Delete the 'Save Settings' button added by FieldUI.
  unset($form['actions']);
  $form = parent::configureForm($form, $form_state, $flexiform);

  // Unset the label field added by  FlexiformElementBase.
  unset($form['label']);

  // Allow the field label to be longer.
  $form['instance']['label']['#maxlength'] = NULL;
  return $form;
}