3 namespace Drupal\form_test;
5 use Drupal\Core\Form\ConfigFormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Provides a test form object that needs arguments.
13 class FormTestArgumentsObject extends ConfigFormBase {
18 public function getFormId() {
19 return 'form_test_form_test_arguments_object';
25 protected function getEditableConfigNames() {
26 return ['form_test.object'];
32 public function buildForm(array $form, FormStateInterface $form_state, $arg = NULL) {
33 $form['element'] = ['#markup' => 'The FormTestArgumentsObject::buildForm() method was used for this form.'];
36 '#type' => 'textfield',
37 '#default_value' => $arg,
38 '#title' => $this->t('Bananas'),
41 $form['actions']['#type'] = 'actions';
42 $form['actions']['submit'] = [
44 '#value' => $this->t('Save'),
52 public function validateForm(array &$form, FormStateInterface $form_state) {
53 drupal_set_message($this->t('The FormTestArgumentsObject::validateForm() method was used for this form.'));
59 public function submitForm(array &$form, FormStateInterface $form_state) {
60 drupal_set_message($this->t('The FormTestArgumentsObject::submitForm() method was used for this form.'));
61 $this->config('form_test.object')
62 ->set('bananas', $form_state->getValue('bananas'))