Add field CSS class support for `DateFormField`
authorMatthias Schmidt <gravatronics@live.com>
Sun, 20 Dec 2020 09:47:00 +0000 (10:47 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 20 Dec 2020 09:47:00 +0000 (10:47 +0100)
com.woltlab.wcf/templates/__dateFormField.tpl
wcfsetup/install/files/acp/templates/__dateFormField.tpl
wcfsetup/install/files/lib/system/form/builder/field/DateFormField.class.php

index c5a4218ad07f38e9509183c17d4c3d934a6f3f5d..8a09c0013ce6287e6c94b1e34cf312921f4ea055 100644 (file)
@@ -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}{*
index c5a4218ad07f38e9509183c17d4c3d934a6f3f5d..8a09c0013ce6287e6c94b1e34cf312921f4ea055 100644 (file)
@@ -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}{*
index afd04a4a405adcffb024b6baed360886d5475d7f..78fd7c3b63a075042420c67f4141a0dc82f4cba8 100644 (file)
@@ -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.