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.
11 class FormTestArgumentsObject extends ConfigFormBase {
16 public function getFormId() {
17 return 'form_test_form_test_arguments_object';
23 protected function getEditableConfigNames() {
24 return ['form_test.object'];
30 public function buildForm(array $form, FormStateInterface $form_state, $arg = NULL) {
31 $form['element'] = ['#markup' => 'The FormTestArgumentsObject::buildForm() method was used for this form.'];
34 '#type' => 'textfield',
35 '#default_value' => $arg,
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 FormTestArgumentsObject::validateForm() method was used for this form.'));
57 public function submitForm(array &$form, FormStateInterface $form_state) {
58 drupal_set_message($this->t('The FormTestArgumentsObject::submitForm() method was used for this form.'));
59 $this->config('form_test.object')
60 ->set('bananas', $form_state->getValue('bananas'))