function webform_cards_form_webform_edit_form_alter in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_cards/webform_cards.module \webform_cards_form_webform_edit_form_alter()
Implements hook_form_FORM_ID_alter() for webform UI and source edit form.
See also
\Drupal\webform_ui\WebformUiEntityElementsForm
File
- modules/
webform_cards/ webform_cards.module, line 273 - Provides a 'Card' container element for clientside multistep form pagination.
Code
function webform_cards_form_webform_edit_form_alter(array &$form, FormStateInterface $form_state) {
if (!isset($form['webform_ui_elements'])) {
return;
}
/** @var \Drupal\webform_ui\WebformUiEntityElementsForm $form_object */
$form_object = $form_state
->getFormObject();
/** @var \Drupal\webform\WebformInterface $webform */
$webform = $form_object
->getEntity();
$wrapper_format = \Drupal::request()
->get(MainContentViewSubscriber::WRAPPER_FORMAT);
$is_ajax_request = $wrapper_format === 'drupal_ajax';
if ($webform
->hasWizardPages() && !$is_ajax_request) {
$form['webform_cards_convert'] = [
'#type' => 'webform_message',
'#message_message' => [
'message' => [
'#markup' => t("Do you want to convert this webform's wizard pages to cards?"),
],
'link' => [
'#type' => 'link',
'#title' => t('Convert'),
'#url' => Url::fromRoute('entity.webform.cards_convert_form', [
'webform' => $webform
->id(),
]),
'#attributes' => WebformDialogHelper::getModalDialogAttributes(WebformDialogHelper::DIALOG_NARROW, [
'button',
'button--small',
]),
'#prefix' => ' ',
],
],
'#message_type' => 'info',
'#message_close' => TRUE,
'#message_storage' => WebformMessage::STORAGE_SESSION,
'#message_id' => 'webform_card_convert_' . $webform
->id(),
'#weight' => -100,
];
}
$form['#attached']['library'][] = 'webform_cards/webform_cards.admin';
}