Fix issues with ItemListFormField
authorMatthias Schmidt <gravatronics@live.com>
Wed, 18 Jul 2018 17:04:53 +0000 (19:04 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 18 Jul 2018 17:04:53 +0000 (19:04 +0200)
See #2509

wcfsetup/install/files/acp/templates/__itemListFormField.tpl
wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php

index 8dd2725e2ca68ec24a33ace1cdb8dc6b503ae0c0..531e754d40354e5f8d079b7f9118c1dadf3d8040 100644 (file)
@@ -1,6 +1,6 @@
 {include file='__formFieldHeader'}
 
-<input type="text" id="{@$field->getPrefixedId()}" name="{@$field->getPrefixedId()}" value="{$field->getValue()}" class="long"{if $field->isAutofocused()} autofocus{/if}{if $field->isRequired()} required{/if}{if $field->isImmutable()} disabled{/if}>
+<input type="text" id="{@$field->getPrefixedId()}" name="{@$field->getPrefixedId()}" value="{$field->getValue()}" class="long"{if $field->isAutofocused()} autofocus{/if}{if $field->isImmutable()} disabled{/if}>
 
 <script data-relocate="true">
        require(['WoltLabSuite/Core/Ui/ItemList/Static'], function(UiItemListStatic) {
index 4801ea2c31320700eb0efd298b31d932dea92e5e..6f553b582b8859161f225052a0fdbbea2cc616cf 100644 (file)
@@ -197,6 +197,10 @@ class ItemListFormField extends AbstractFormField {
                        $invalidItems = [];
                        foreach ($this->getValue() as $item) {
                                switch ($this->getSaveValueType()) {
+                                       case self::SAVE_VALUE_TYPE_ARRAY:
+                                               // nothing
+                                               break;
+                                       
                                        case self::SAVE_VALUE_TYPE_CSV:
                                                if (strpos($item, ',') !== false) {
                                                        $invalidItems[] = $item;
@@ -227,6 +231,9 @@ class ItemListFormField extends AbstractFormField {
                                ));
                        }
                }
+               else if ($this->isRequired()) {
+                       $this->addValidationError(new FormFieldValidationError('empty'));
+               }
                
                parent::validate();
        }