spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.64k stars 38.14k forks source link

form:label is broken for checkboxes [SPR-7452] #12110

Closed spring-projects-issues closed 9 years ago

spring-projects-issues commented 14 years ago

Axel Fontaine opened SPR-7452 and commented

The following jsp code:

My Box Label</form:label>

gets translated to

\\\

This is wrong!

The correct code should be

...\

Cheers, Axel

P.S.: #8226 got fixed automatically with the move to Java 5 and autoboxing


Affects: 3.0.3

4 votes, 5 watchers

spring-projects-issues commented 14 years ago

Juergen Hoeller commented

This is actually why has a 'label' attribute: If you specify a value there, it'll be rendered as a label for the specific id of the checkbox. Whereas a separate tag is basically independent from the checkbox tag and renders a label for the specified bean property path.

Juergen

spring-projects-issues commented 14 years ago

Axel Fontaine commented

Well, the label attribute is nice for the most basic situations. As soon as you want sopmething even as simple as assigning an id to the label, you're out of luck.

Why can't the checkbox have the same id as its name? This would solve this issue automatically.

spring-projects-issues commented 12 years ago

Marc Wiest commented

I agree with Axel. I need a cssClass on the label for example. I guess the problem is, that there can be multiple checkboxes or radio buttons with the same path and different values. So, I'd suggest one of the following:

  1. Add labelCssCass, labelId, etc. attributes to form:checkbox (and form:radiobutton)

  2. Add a value attribute to form:label, in order to match the checkbox/radiobutton with the given value. Unfortunately the values don't have to be unique, so this seems not very elegant.

Right now, we're stuck with using and \

spring-projects-issues commented 9 years ago

Juergen Hoeller commented

Closing groups of outdated issues. Please reopen if still relevant.