Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294747

using formBuilder()->getForm() doesn't allow text_area to be passed to submit handler

$
0
0

I created a form that I wanted to be reusable. So I created the form below to imported it into a add form and a edit form. Please be aware I do have the validateForm, and submitForm function in my code.

class PaneConfigurationForm extends ConfigFormBase {

    /**
     * {@inheritdoc}
     */
    public function getFormId() {
        return 'admin_pane_settings';
    }

    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state, $element = null) {

       $form['description'] = array(
          '#type' => 'text_format',
          '#title' => 'description',
          '#default_value' => '<p>The quick brown fox jumped over the lazy dog.</p>',
          '#value' => '<p>The quick brown fox jumped over the lazy dog.</p>',
          '#format' => 'full_html',
       );

       return parent::buildForm($form, $form_state);
    }
}

So in my AddPane form I use the \Drupal::formBuilder()->getForm() function to get the form and apply it to my parent form. For some reason when I submit the form the value is not passed to the submit handler, only to form format is. Other fields seem to work fine, just not text_format.

class AddPaneForm extends Formbase {

    /**
     * {@inheritdoc}
     */
    public function getFormId() {
        return 'add_admin_pane';
    }

    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state, $element = null) {


          $form = \Drupal::formBuilder()->getForm('Drupal\_module_\Form\PaneConfigurationForm');

          $form['actions']['submit'] = array(
            '#type' => 'submit',
            '#value' => $this->t('Save'),
          );
    }

    public function submitForm(array &$form, FormStateInterface $form_state)
    {
          $form_state->getValue('description')
    }
}

Viewing all articles
Browse latest Browse all 294747

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>