3 namespace Drupal\form_test;
5 use Drupal\Core\Form\ConfigFormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Provides a test form object.
11 class FormTestServiceObject extends ConfigFormBase {
16 public function getFormId() {
17 return 'form_test_form_test_service_object';
23 protected function getEditableConfigNames() {
24 return ['form_test.object'];
30 public function buildForm(array $form, FormStateInterface $form_state) {
31 $form['element'] = ['#markup' => 'The FormTestServiceObject::buildForm() method was used for this form.'];
34 '#type' => 'textfield',
35 '#default_value' => 'brown',
36 '#title' => $this->t('Bananas'),
39 $form['actions']['#type'] = 'actions';
40 $form['actions']['submit'] = [
42 '#value' => $this->t('Save'),
50 public function validateForm(array &$form, FormStateInterface $form_state) {
51 drupal_set_message($this->t('The FormTestServiceObject::validateForm() method was used for this form.'));
57 public function submitForm(array &$form, FormStateInterface $form_state) {
58 drupal_set_message($this->t('The FormTestServiceObject::submitForm() method was used for this form.'));
59 $this->config('form_test.object', FALSE)
60 ->set('bananas', $form_state->getValue('bananas'))