+++ /dev/null
-<script data-relocate="true">
- {* register form with dependency manager before any form field-related JavaScript code is executed below *}
- require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager'], function(FormBuilderFieldDependencyManager) {
- FormBuilderFieldDependencyManager.register('{@$form->getId()}');
- });
-</script>
-
-{if $form->getAction()}
- {capture assign='__formStart'}<form method="{@$form->getMethod()}" action="{@$form->getAction()}"{/capture}
- {assign var='__formEnd' value='</form>'}
-{else}
- {assign var='__formStart' value='<section'}
- {assign var='__formEnd' value='</section>'}
-{/if}
-
-{@$__formStart} id="{@$form->getId()}"{if !$form->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}
-
- <div class="formSubmit">
- <button class="buttonPrimary">{lang}wcf.global.button.submit{/lang}</button>
- {if $form->isCancelable()}
- <button data-type="cancel">{lang}wcf.global.button.cancel{/lang}</button>
- {/if}
- </div>
-{@$__formEnd}
-
-<script data-relocate="true">
- {* after all dependencies have been added, check them *}
- require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager'], function(FormBuilderFieldDependencyManager) {
- FormBuilderFieldDependencyManager.checkDependencies();
- });
-</script>
"__booleanFormField",
"__dateFormField",
"__devtoolsLanguageChooser",
- "__dialogForm",
"__form",
"__formButton",
"__formContainer",
+++ /dev/null
-<script data-relocate="true">
- {* register form with dependency manager before any form field-related JavaScript code is executed below *}
- require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager'], function(FormBuilderFieldDependencyManager) {
- FormBuilderFieldDependencyManager.register('{@$form->getId()}');
- });
-</script>
-
-{if $form->getAction()}
- {capture assign='__formStart'}<form method="{@$form->getMethod()}" action="{@$form->getAction()}"{/capture}
- {assign var='__formEnd' value='</form>'}
-{else}
- {assign var='__formStart' value='<section'}
- {assign var='__formEnd' value='</section>'}
-{/if}
-
-{@$__formStart} id="{@$form->getId()}"{if !$form->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}
-
- <div class="formSubmit">
- <button class="buttonPrimary">{lang}wcf.global.button.submit{/lang}</button>
- {if $form->isCancelable()}
- <button data-type="cancel">{lang}wcf.global.button.cancel{/lang}</button>
- {/if}
- </div>
-{@$__formEnd}
-
-<script data-relocate="true">
- {* after all dependencies have been added, check them *}
- require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager'], function(FormBuilderFieldDependencyManager) {
- FormBuilderFieldDependencyManager.checkDependencies();
- });
-</script>
<?php
namespace wcf\system\form\builder;
-use wcf\system\WCF;
+use wcf\system\form\builder\button\FormButton;
/**
* Represents a form (document) in a dialog.
*
+ * By default, the global form error message is now shown for dialog forms and it is assumed that
+ * the form is requested via an AJAX request.
+ *
* @author Matthias Schmidt
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @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
*/
/**
* @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')
+ );
+ }
}
/**