</form>
{/if}
+{if $form->needsRequiredFieldsInfo()}
+ <div class="section requiredFieldsInfo">
+ <p><span class="formFieldRequired">*</span> {lang}wcf.global.form.required{/lang}</p>
+
+ {event name='requiredFieldsInfo'}
+ </div>
+{/if}
+
<script data-relocate="true">
{* after all dependencies have been added, check them *}
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager'], function(FormBuilderFieldDependencyManager) {
{if $container->getLabel() !== null}
{if $container->getDescription() !== null}
<header class="sectionHeader">
- <h2 class="sectionTitle">{@$container->getLabel()}</h2>
+ <h2 class="sectionTitle">{@$container->getLabel()}{if $container->markAsRequired()} <span class="formFieldRequired">*</span>{/if}</h2>
<p class="sectionDescription">{@$container->getDescription()}</p>
</header>
{else}
- <h2 class="sectionTitle">{@$container->getLabel()}</h2>
+ <h2 class="sectionTitle">{@$container->getLabel()}{if $container->markAsRequired()} <span class="formFieldRequired">*</span>{/if}</h2>
{/if}
{/if}
<dl id="{@$field->getPrefixedId()}Container" {if !$field->getClasses()|empty} class="{implode from=$field->getClasses() item='class' glue=' '}{$class}{/implode}"{/if}{foreach from=$field->getAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}{if !$field->checkDependencies()} style="display: none;"{/if}>
- <dt>{if $field->getLabel() !== null}<label for="{@$field->getPrefixedId()}">{@$field->getLabel()}</label>{/if}</dt>
+ <dt>{if $field->getLabel() !== null}<label for="{@$field->getPrefixedId()}">{@$field->getLabel()}</label>{if $field->isRequired()} <span class="formFieldRequired">*</span>{/if}{/if}</dt>
<dd>
{@$field->getFieldHtml()}
</form>
{/if}
+{if $form->needsRequiredFieldsInfo()}
+ <div class="section requiredFieldsInfo">
+ <p><span class="formFieldRequired">*</span> {lang}wcf.global.form.required{/lang}</p>
+
+ {event name='requiredFieldsInfo'}
+ </div>
+{/if}
+
<script data-relocate="true">
{* after all dependencies have been added, check them *}
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager'], function(FormBuilderFieldDependencyManager) {
{if $container->getLabel() !== null}
{if $container->getDescription() !== null}
<header class="sectionHeader">
- <h2 class="sectionTitle">{@$container->getLabel()}</h2>
+ <h2 class="sectionTitle">{@$container->getLabel()}{if $container->markAsRequired()} <span class="formFieldRequired">*</span>{/if}</h2>
<p class="sectionDescription">{@$container->getDescription()}</p>
</header>
{else}
- <h2 class="sectionTitle">{@$container->getLabel()}</h2>
+ <h2 class="sectionTitle">{@$container->getLabel()}{if $container->markAsRequired()} <span class="formFieldRequired">*</span>{/if}</h2>
{/if}
{/if}
<dl id="{@$field->getPrefixedId()}Container" {if !$field->getClasses()|empty} class="{implode from=$field->getClasses() item='class' glue=' '}{$class}{/implode}"{/if}{foreach from=$field->getAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}{if !$field->checkDependencies()} style="display: none;"{/if}>
- <dt>{if $field->getLabel() !== null}<label for="{@$field->getPrefixedId()}">{@$field->getLabel()}</label>{/if}</dt>
+ <dt>{if $field->getLabel() !== null}<label for="{@$field->getPrefixedId()}">{@$field->getLabel()}</label>{if $field->isRequired()} <span class="formFieldRequired">*</span>{/if}{/if}</dt>
<dd>
{@$field->getFieldHtml()}
return $this->invalid;
}
+ /**
+ * @inheritDoc
+ * @since 5.3
+ */
+ public function needsRequiredFieldsInfo() {
+ /** @var IFormNode $node */
+ foreach ($this->getIterator() as $node) {
+ if (
+ $node->isAvailable()
+ && $node instanceof IFormElement
+ && $node->getLabel() !== null
+ && (
+ ($node instanceof IFormContainer && $node->markAsRequired())
+ || ($node instanceof IFormField && $node->isRequired())
+ )
+ ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* @inheritDoc
*/
*/
public function invalid($invalid = true);
+ /**
+ * Returns `true` if the information about required fields has to be shown below the form.
+ *
+ * @return bool
+ * @since 5.3
+ */
+ public function needsRequiredFieldsInfo();
+
/**
* Sets the updated object (and loads the field values from the given object) and returns
* this document.
);
}
+ /**
+ * @inheritDoc
+ * @since 5.3
+ */
+ public function markAsRequired() {
+ return false;
+ }
+
/**
* @inheritDoc
*/
* @since 5.2
*/
interface IFormContainer extends IFormChildNode, IFormElement, IFormParentNode {
+ /**
+ * Returns `true` if the whole container should be marked as required in the form output.
+ *
+ * @return bool
+ * @since 5.3
+ */
+ public function markAsRequired();
+
/**
* Informs the form container of the updated object and this method is called by
* `IFormDocument::updatedObject()` to inform the container that object data is being loaded.
return $this->required;
}
+ /**
+ * @since 5.3
+ * @inheritDoc
+ */
+ public function markAsRequired() {
+ return $this->getWysiwygField()->isRequired();
+ }
+
/**
* Sets the message object type used by the wysiwyg form field.
*
}
}
+.formFieldRequired,
.customOptionRequired {
color: rgba(204, 0, 1, 1) !important;
}