public function YamlFormUiElementTestForm::submitForm in YAML Form 8
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides YamlFormUiElementFormBase::submitForm
File
- modules/
yamlform_ui/ src/ Form/ YamlFormUiElementTestForm.php, line 177
Class
- YamlFormUiElementTestForm
- Provides a test form for form elements.
Namespace
Drupal\yamlform_ui\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Rebuild is throwing the below error.
// LogicException: Settings can not be serialized.
// $form_state->setRebuild();
// @todo Determine what object is being serialized with form.
// The form element configuration is stored in the 'properties' key in
// the form, pass that through for submission.
$element_form_state = clone $form_state;
$element_form_state
->setValues($form_state
->getValue('properties'));
$properties = $this->yamlformElement
->getConfigurationFormProperties($form, $element_form_state);
// Set #default_value using 'test' element value.
if ($element_value = $form_state
->getValue('element')) {
$properties['#default_value'] = $element_value;
}
\Drupal::request()
->getSession()
->set('yamlform_ui_test_element_' . $this->type, $properties);
drupal_set_message($this
->t('Form element %type test has been updated.', [
'%type' => $this->type,
]));
}