【发布时间】:2017-10-16 13:46:54
【问题描述】:
当用户从前端单击链接时,我想在弹出窗口中显示我的自定义表单,我尝试了许多在网络中显示但对我不起作用的解决方案。
这是我的代码。
$response = new AjaxResponse();
// Get the modal form using the form builder.
$modal_form = $this->formBuilder->getForm('Drupal\fwsactions\Forms\FwsActionsForm');
$modal_form['#attached']['library'][] = 'core/drupal.dialog.ajax';
// Add an AJAX command to open a modal dialog with the form as the content.
$modal_form = render($modal_form);
$response->addCommand(new OpenModalDialogCommand('My Modal Form', $modal_form, ['width' => '800']));
return $response;
我应该怎么做才能通过单击链接打开此表单。
【问题讨论】:
标签: drupal drupal-modules drupal-8