function CopyFieldValueTestForm::buildForm

Same name in other branches
  1. 11.x core/modules/system/tests/modules/system_test/src/Form/CopyFieldValueTestForm.php \Drupal\system_test\Form\CopyFieldValueTestForm::buildForm()

Overrides FormInterface::buildForm

File

core/modules/system/tests/modules/system_test/src/Form/CopyFieldValueTestForm.php, line 23

Class

CopyFieldValueTestForm
Provides a form to test Drupal.behaviors.copyFieldValue.

Namespace

Drupal\system_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['#attached']['library'][] = 'system/drupal.system';
    $form['#attached']['drupalSettings']['copyFieldValue']['edit-source-field'] = [
        'edit-target-field',
    ];
    $form['source_field'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Source Field'),
        '#default_value' => '',
        '#description' => $this->t('Source input field to provide text value.'),
        '#required' => TRUE,
    ];
    $form['target_field'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Target Field'),
        '#default_value' => '',
        '#description' => $this->t('Target input field to get value from source field.'),
        '#required' => TRUE,
    ];
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.