Skip to content

Velocity springFormCheckbox results in checkboxes that are always checked [SPR-6120] #10788

Closed
@spring-projects-issues

Description

@spring-projects-issues

Richard Paul opened SPR-6120 and commented

In Spring 3.0 the Velocity macro spring.vm introduces springFormCheckbox, a handy macro for generating a checkbox and associated field marker.
However there is a bug in the implementation which causes the checkbox to always be checked. This is due to the way the checked attribute is used in HTML, if a checked attribute is present, regardless of its value, then the checkbox is checked. The macro writes checked="false" when the input should not be selected, resulting in the attribute actually being checked.

Currently:
<input type="checkbox" id="${status.expression}" name="${status.expression}" checked="#if("$!{status.value}"=="true")true#{else}false#end" ${attributes}/>

Should be:
<input type="checkbox" id="${status.expression}" name="${status.expression}" #if("$!{status.value}"=="true")checked="true"#end ${attributes}/>


Affects: 3.0 M4

Issue Links:

Referenced from: commits 6420fd3

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions