Skip to content

Commit 71cd2f3

Browse files
committed
Allow empty value in RadioButtonFormField
1 parent 14543f8 commit 71cd2f3

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

com.woltlab.wcf/templates/shared_radioButtonFormField.tpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
{if !$field->isRequired()}
2+
<label>
3+
<input {*
4+
*}type="radio" {*
5+
*}name="{$field->getPrefixedId()}" {*
6+
*}value="" {*
7+
*}{if !$field->getFieldClasses()|empty} class="{implode from=$field->getFieldClasses() item='class' glue=' '}{$class}{/implode}"{/if}{*
8+
*}{if $field->getValue() !== null && $field->getValue() == ''} checked{/if}{*
9+
*}{if $field->isImmutable()} disabled{/if}{*
10+
*}{foreach from=$field->getFieldAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}{*
11+
*}> {lang}wcf.global.noSelection{/lang}
12+
</label>
13+
{/if}
114
{foreach from=$field->getOptions() key=$__fieldValue item=__fieldLabel}
215
<label>
316
<input {*

wcfsetup/install/files/lib/system/form/builder/field/RadioButtonFormField.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function supportsNestedOptions()
6262
*/
6363
public function validate()
6464
{
65-
if (!isset($this->getOptions()[$this->getValue()])) {
65+
if ($this->isRequired() && !isset($this->getOptions()[$this->getValue()])) {
6666
$this->addValidationError(new FormFieldValidationError(
6767
'invalidValue',
6868
'wcf.global.form.error.noValidSelection'

0 commit comments

Comments
 (0)