get('config.factory') ); } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, $custom_attributes = NULL) { $form['element'] = ['#markup' => 'The FormTestControllerObject::buildForm() method was used for this form.']; $form['custom_attribute']['#markup'] = $custom_attributes; $form['request_attribute']['#markup'] = $request->attributes->get('request_attribute'); $form['bananas'] = [ '#type' => 'textfield', '#title' => $this->t('Bananas'), ]; $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Save'), ]; return $form; } /** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The FormTestControllerObject::validateForm() method was used for this form.')); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The FormTestControllerObject::submitForm() method was used for this form.')); $this->config('form_test.object') ->set('bananas', $form_state->getValue('bananas')) ->save(); } }