From 49baa59a7afd30f8e582a1eba041f0d65fce95cc Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 20 Dec 2020 10:47:00 +0100 Subject: [PATCH] Add field CSS class support for `DateFormField` --- com.woltlab.wcf/templates/__dateFormField.tpl | 4 ++-- .../install/files/acp/templates/__dateFormField.tpl | 4 ++-- .../system/form/builder/field/DateFormField.class.php | 10 +++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/com.woltlab.wcf/templates/__dateFormField.tpl b/com.woltlab.wcf/templates/__dateFormField.tpl index c5a4218ad0..8a09c0013c 100644 --- a/com.woltlab.wcf/templates/__dateFormField.tpl +++ b/com.woltlab.wcf/templates/__dateFormField.tpl @@ -2,8 +2,8 @@ *}type="{if $field->supportsTime()}datetime{else}date{/if}" {* *}id="{@$field->getPrefixedId()}" {* *}name="{@$field->getPrefixedId()}" {* - *}value="{$field->getValue()}" {* - *}class="medium"{* + *}value="{$field->getValue()}"{* + *}{if !$field->getFieldClasses()|empty} class="{implode from=$field->getFieldClasses() item='class' glue=' '}{$class}{/implode}"{/if}{* *}{if $field->isAutofocused()} autofocus{/if}{* *}{if $field->isRequired()} required{/if}{* *}{if $field->isImmutable()} disabled{/if}{* diff --git a/wcfsetup/install/files/acp/templates/__dateFormField.tpl b/wcfsetup/install/files/acp/templates/__dateFormField.tpl index c5a4218ad0..8a09c0013c 100644 --- a/wcfsetup/install/files/acp/templates/__dateFormField.tpl +++ b/wcfsetup/install/files/acp/templates/__dateFormField.tpl @@ -2,8 +2,8 @@ *}type="{if $field->supportsTime()}datetime{else}date{/if}" {* *}id="{@$field->getPrefixedId()}" {* *}name="{@$field->getPrefixedId()}" {* - *}value="{$field->getValue()}" {* - *}class="medium"{* + *}value="{$field->getValue()}"{* + *}{if !$field->getFieldClasses()|empty} class="{implode from=$field->getFieldClasses() item='class' glue=' '}{$class}{/implode}"{/if}{* *}{if $field->isAutofocused()} autofocus{/if}{* *}{if $field->isRequired()} required{/if}{* *}{if $field->isImmutable()} disabled{/if}{* diff --git a/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php index afd04a4a40..78fd7c3b63 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php @@ -13,8 +13,9 @@ use wcf\util\DateUtil; * @package WoltLabSuite\Core\System\Form\Builder\Field * @since 5.2 */ -class DateFormField extends AbstractFormField implements IAutoFocusFormField, IImmutableFormField, INullableFormField { +class DateFormField extends AbstractFormField implements IAutoFocusFormField, ICssClassFormField, IImmutableFormField, INullableFormField { use TAutoFocusFormField; + use TCssClassFormField; use TImmutableFormField; use TNullableFormField; @@ -57,6 +58,13 @@ class DateFormField extends AbstractFormField implements IAutoFocusFormField, II const DATE_FORMAT = 'Y-m-d'; const TIME_FORMAT = 'Y-m-d\TH:i:sP'; + /** + * Creates a new instance of `DateFormField`. + */ + public function __construct() { + $this->addFieldClass('medium'); + } + /** * Sets the earliest valid date in `DateFormField::$saveValueFormat` format and returns this * field. If `null` is given, the previously set earliest valid date is unset. -- 2.20.1