You are here

class DurationElementStatesTestForm in Duration Field 8.2

Same name and namespace in other branches
  1. 3.0.x tests/modules/duration_field_form_test/src/Form/DurationElementStatesTestForm.php \Drupal\duration_field_form_test\Form\DurationElementStatesTestForm

Form for testing JavaScript #states behavior on 'duration' elements.

Hierarchy

Expanded class hierarchy of DurationElementStatesTestForm

1 string reference to 'DurationElementStatesTestForm'
duration_field_form_test.routing.yml in tests/modules/duration_field_form_test/duration_field_form_test.routing.yml
tests/modules/duration_field_form_test/duration_field_form_test.routing.yml

File

tests/modules/duration_field_form_test/src/Form/DurationElementStatesTestForm.php, line 11

Namespace

Drupal\duration_field_form_test\Form
View source
class DurationElementStatesTestForm implements FormInterface {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'duration_form_element_states_test';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

    // Trigger element.
    $form['checkbox_trigger'] = [
      '#type' => 'checkbox',
      '#title' => 'Checkbox trigger',
    ];

    // Duration elements that respond to the trigger.
    $form['duration_invisible_when_checkbox_trigger_checked'] = [
      '#type' => 'duration',
      '#title' => 'Duration invisible when checkbox trigger checked',
      '#states' => [
        'invisible' => [
          ':input[name="checkbox_trigger"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    ];
    $form['submit'] = [
      '#type' => 'submit',
      '#value' => t('Submit'),
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DurationElementStatesTestForm::buildForm public function Form constructor. Overrides FormInterface::buildForm
DurationElementStatesTestForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
DurationElementStatesTestForm::submitForm public function Form submission handler. Overrides FormInterface::submitForm
DurationElementStatesTestForm::validateForm public function Form validation handler. Overrides FormInterface::validateForm