function DbtngExampleAddForm::buildForm
Same name in other branches
- 4.0.x modules/dbtng_example/src/Form/DbtngExampleAddForm.php \Drupal\dbtng_example\Form\DbtngExampleAddForm::buildForm()
Overrides FormInterface::buildForm
File
-
modules/
dbtng_example/ src/ Form/ DbtngExampleAddForm.php, line 76
Class
- DbtngExampleAddForm
- Form to add a database entry, with all the interesting fields.
Namespace
Drupal\dbtng_example\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form = [];
$form['message'] = [
'#markup' => $this->t('Add an entry to the dbtng_example table.'),
];
$form['add'] = [
'#type' => 'fieldset',
'#title' => $this->t('Add a person entry'),
];
$form['add']['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#size' => 15,
];
$form['add']['surname'] = [
'#type' => 'textfield',
'#title' => $this->t('Surname'),
'#size' => 15,
];
$form['add']['age'] = [
'#type' => 'textfield',
'#title' => $this->t('Age'),
'#size' => 5,
'#description' => $this->t("Values greater than 127 will cause an exception. Try it - it's a great example why exception handling is needed with DTBNG."),
];
$form['add']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Add'),
];
return $form;
}