FormTestGroupFieldsetForm.php

Same filename in other branches
  1. 9 core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php
  2. 10 core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php
  3. 11.x core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php

Namespace

Drupal\form_test\Form

File

core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php

View source
<?php

namespace Drupal\form_test\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Builds a simple form to test the #group property on #type 'fieldset'.
 *
 * @internal
 */
class FormTestGroupFieldsetForm extends FormBase {
    
    /**
     * {@inheritdoc}
     */
    public function getFormId() {
        return 'form_test_group_fieldset';
    }
    
    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state, $required = FALSE) {
        $form['fieldset'] = [
            '#type' => 'fieldset',
            '#title' => 'Fieldset',
            '#required' => !empty($required),
        ];
        $form['meta'] = [
            '#type' => 'container',
            '#title' => 'Group element',
            '#group' => 'fieldset',
        ];
        $form['meta']['element'] = [
            '#type' => 'textfield',
            '#title' => 'Nest in container element',
        ];
        return $form;
    }
    
    /**
     * {@inheritdoc}
     */
    public function submitForm(array &$form, FormStateInterface $form_state) {
    }

}

Classes

Title Deprecated Summary
FormTestGroupFieldsetForm Builds a simple form to test the #group property on #type 'fieldset'.

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