function FormTestObject::buildForm
Same name in other branches
- 9 core/modules/system/tests/modules/form_test/src/FormTestObject.php \Drupal\form_test\FormTestObject::buildForm()
- 8.9.x core/modules/system/tests/modules/form_test/src/FormTestObject.php \Drupal\form_test\FormTestObject::buildForm()
- 11.x core/modules/system/tests/modules/form_test/src/FormTestObject.php \Drupal\form_test\FormTestObject::buildForm()
Overrides ConfigFormBase::buildForm
File
-
core/
modules/ system/ tests/ modules/ form_test/ src/ FormTestObject.php, line 32
Class
- FormTestObject
- Provides a test form object.
Namespace
Drupal\form_testCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['element'] = [
'#markup' => 'The FormTestObject::buildForm() method was used for this form.',
];
$form['bananas'] = [
'#type' => 'textfield',
'#title' => $this->t('Bananas'),
];
$form['strawberry'] = [
'#type' => 'hidden',
'#value' => 'red',
'#attributes' => [
'id' => 'red-strawberry-hidden-field',
],
];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
];
$form['#title'] = 'Test dynamic title';
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.