function FormTestUrlForm::buildForm

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php \Drupal\form_test\Form\FormTestUrlForm::buildForm()
  2. 8.9.x core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php \Drupal\form_test\Form\FormTestUrlForm::buildForm()
  3. 10 core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php \Drupal\form_test\Form\FormTestUrlForm::buildForm()

Overrides FormInterface::buildForm

File

core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php, line 26

Class

FormTestUrlForm
Form constructor for testing #type 'url' elements.

Namespace

Drupal\form_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['url'] = [
        '#type' => 'url',
        '#title' => 'Optional URL',
        '#description' => 'An optional URL field.',
    ];
    $form['url_required'] = [
        '#type' => 'url',
        '#title' => 'Required URL',
        '#description' => 'A required URL field.',
        '#required' => TRUE,
    ];
    $form['submit'] = [
        '#type' => 'submit',
        '#value' => 'Submit',
    ];
    return $form;
}

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