From: Matthias Schmidt Date: Sun, 17 Mar 2019 07:55:40 +0000 (+0100) Subject: Update form builder's dialog form document implementation X-Git-Tag: 5.2.0_Alpha_1~210 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ed643412f3e509b09d8b724d9d28b7c3e5131f46;p=GitHub%2FWoltLab%2FWCF.git Update form builder's dialog form document implementation See #2509 --- diff --git a/com.woltlab.wcf/templates/__dialogForm.tpl b/com.woltlab.wcf/templates/__dialogForm.tpl deleted file mode 100644 index d42513b72f..0000000000 --- a/com.woltlab.wcf/templates/__dialogForm.tpl +++ /dev/null @@ -1,36 +0,0 @@ - - -{if $form->getAction()} - {capture assign='__formStart'}
getClasses()|empty} class="{implode from=$form->getClasses() item='class' glue=' '}{$class}{/implode}"{/if}{foreach from=$form->getAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}> - {foreach from=$form item='child'} - {if $child->isAvailable()} - {@$child->getHtml()} - {/if} - {/foreach} - -
- - {if $form->isCancelable()} - - {/if} -
-{@$__formEnd} - - diff --git a/syncTemplates.json b/syncTemplates.json index f98b8e2307..62a00302cd 100644 --- a/syncTemplates.json +++ b/syncTemplates.json @@ -8,7 +8,6 @@ "__booleanFormField", "__dateFormField", "__devtoolsLanguageChooser", - "__dialogForm", "__form", "__formButton", "__formContainer", diff --git a/wcfsetup/install/files/acp/templates/__dialogForm.tpl b/wcfsetup/install/files/acp/templates/__dialogForm.tpl deleted file mode 100644 index d42513b72f..0000000000 --- a/wcfsetup/install/files/acp/templates/__dialogForm.tpl +++ /dev/null @@ -1,36 +0,0 @@ - - -{if $form->getAction()} - {capture assign='__formStart'}getClasses()|empty} class="{implode from=$form->getClasses() item='class' glue=' '}{$class}{/implode}"{/if}{foreach from=$form->getAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}> - {foreach from=$form item='child'} - {if $child->isAvailable()} - {@$child->getHtml()} - {/if} - {/foreach} - -
- - {if $form->isCancelable()} - - {/if} -
-{@$__formEnd} - - diff --git a/wcfsetup/install/files/lib/system/form/builder/DialogFormDocument.class.php b/wcfsetup/install/files/lib/system/form/builder/DialogFormDocument.class.php index 960db3b86d..781a0876f5 100644 --- a/wcfsetup/install/files/lib/system/form/builder/DialogFormDocument.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/DialogFormDocument.class.php @@ -1,10 +1,13 @@ @@ -12,15 +15,27 @@ use wcf\system\WCF; * @since 5.2 */ class DialogFormDocument extends FormDocument { + /** + * @inheritDoc + */ + protected $ajax = true; + /** * is `true` if dialog from can be canceled and is `false` otherwise * @var bool */ protected $isCancelable = true; + /** + * @inheritDoc + */ + protected $showErrorMessage = false; + /** * Sets whether the dialog from can be canceled and return this document. * + * For cancelable dialog forms, a cancel button is added. + * * @param bool $cancelable determines if dialog from can be canceled * @return static this document */ @@ -33,12 +48,16 @@ class DialogFormDocument extends FormDocument { /** * @inheritDoc */ - public function getHtml() { - return WCF::getTPL()->fetch( - '__dialogForm', - 'wcf', - array_merge($this->getHtmlVariables(), ['form' => $this]) - ); + protected function createDefaultButton() { + parent::createDefaultButton(); + + if ($this->isCancelable()) { + $this->addButton( + FormButton::create('cancelButton') + ->attribute('data-type', 'cancel') + ->label('wcf.global.button.cancel') + ); + } } /**