Skip to content
FormTestServiceObject.php 1.51 KiB
Newer Older
use Drupal\Core\Form\ConfigFormBase;
class FormTestServiceObject extends ConfigFormBase {
  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return ['form_test.object'];
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['element'] = ['#markup' => 'The FormTestServiceObject::buildForm() method was used for this form.'];
      '#type' => 'textfield',
      '#default_value' => 'brown',
      '#title' => $this->t('Bananas'),
      '#value' => $this->t('Save'),
  public function validateForm(array &$form, FormStateInterface $form_state) {
    drupal_set_message($this->t('The FormTestServiceObject::validateForm() method was used for this form.'));
  public function submitForm(array &$form, FormStateInterface $form_state) {
    drupal_set_message($this->t('The FormTestServiceObject::submitForm() method was used for this form.'));
    $this->config('form_test.object', FALSE)
      ->set('bananas', $form_state->getValue('bananas'))