public function WebformCardsConvertForm::submitForm in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_cards/src/Form/WebformCardsConvertForm.php \Drupal\webform_cards\Form\WebformCardsConvertForm::submitForm()
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 FormInterface::submitForm
File
- modules/
webform_cards/ src/ Form/ WebformCardsConvertForm.php, line 60
Class
- WebformCardsConvertForm
- Form for converting wizard pages to cards.
Namespace
Drupal\webform_cards\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
/** @var \Drupal\webform\WebformInterface $webform */
$webform = Webform::load($form_state
->getValue('webform_id'));
$elements = $webform
->getElementsRaw();
$elements = str_replace("'#type': webform_wizard_page", "'#type': webform_card", $elements);
$webform
->setElements(Yaml::decode($elements));
$webform
->save();
$this
->messenger()
->addStatus($this
->t('Wizard pages have been successfully converted to cards.'));
$form_state
->setRedirectUrl($webform
->toUrl('edit-form'));
}