Issue Bug Closed

#82457OptionViewHelper ignores empty value

Raphael Graf 09/11/17, 20:43 updated 10/02/18, 10:55

Description

The following code does not produce two selects with the same options:

<f:form.select name="select1" options="{options}" />
<f:form.select name="select2">
    <f:for each="{options}" key="key" as="value">
        <f:form.select.option value="{key}">{value}</f:form.select.option>
    </f:for>
</f:form.select>

$options = ['' => 'empty', 'foo' => 'bar'];
$this->view->assign($options);

The resulting HTML:

<select name="select1">
    <option value="">empty</option>
    <option value="foo">bar</option>
</select>
<select name="select2">
    <option>empty</option>
    <option value="foo">bar</option>
</select>

Note that the submitted value differs if the first option is selected.

Reviews 1