Allow value `0` in select form fields
authorMarcel Werk <burntime@woltlab.com>
Mon, 30 Sep 2024 11:55:20 +0000 (13:55 +0200)
committerMarcel Werk <burntime@woltlab.com>
Mon, 30 Sep 2024 11:55:20 +0000 (13:55 +0200)
Previously, it was not possible to distinguish between value `0` and not selected (`zero`).

com.woltlab.wcf/templates/shared_selectFormField.tpl

index 7c966276e07209f700070c0b5206013289fdc868..2ae1f396bba14f26c0e8f1f23721b5089bb8f50d 100644 (file)
@@ -8,7 +8,7 @@
        {foreach from=$field->getNestedOptions() item=__fieldNestedOption}
                <option
                        value="{$__fieldNestedOption[value]}"
-                       {if $field->getValue() == $__fieldNestedOption[value] && $__fieldNestedOption[isSelectable]} selected{/if}
+                       {if $field->getValue() !== null && $field->getValue() == $__fieldNestedOption[value] && $__fieldNestedOption[isSelectable]} selected{/if}
                        {if $field->isImmutable() || !$__fieldNestedOption[isSelectable]} disabled{/if}
                >{@'&nbsp;'|str_repeat:$__fieldNestedOption[depth] * 4}{@$__fieldNestedOption[label]}</option>
        {/foreach}