带有弹出窗口的Drupal 8自定义表单
我想在弹出窗口中显示我的自定义表单,当用户单击前端的链接时,我尝试了许多在web中显示的解决方案,但不适合我 这是我的密码带有弹出窗口的Drupal 8自定义表单,drupal,drupal-modules,drupal-8,Drupal,Drupal Modules,Drupal 8,我想在弹出窗口中显示我的自定义表单,当用户单击前端的链接时,我尝试了许多在web中显示的解决方案,但不适合我 这是我的密码 $response = new AjaxResponse(); // Get the modal form using the form builder. $modal_form = $this->formBuilder->getForm('Drupal\fwsactions\Forms\FwsActionsFor
$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;
我应该怎么做才能仅通过单击链接打开此表单
$content['overlay_link'] = array(
'#type' => 'link',
'#title' => $this->t('Add movie'),
'#url' => Url::fromRoute('node.add', ['node_type' => 'content_type_movie']),
'#attributes' => [
'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => 700,
]),
],
);
请查看更多详细信息。
这里还有一个可能会有所帮助,虽然两者都是相同的,但仍然是共享的
希望这有帮助