'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' => 'redstrawberryhiddenfield'], ]; $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Save'), ]; $form['#title'] = 'Test dynamic title'; return $form; } /** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { $this->messenger()->addStatus($this->t('The FormTestObject::validateForm() method was used for this form.')); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->messenger()->addStatus($this->t('The FormTestObject::submitForm() method was used for this form.')); $this->config('form_test.object') ->set('bananas', $form_state->getValue('bananas')) ->save(); } }