Version 1
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestGroupFieldsetForm.php
diff --git a/web/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php b/web/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php
new file mode 100644 (file)
index 0000000..37ef246
--- /dev/null
@@ -0,0 +1,47 @@
+<?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'.
+ */
+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) {
+  }
+
+}