Skip to content

Using array syntax generates invalid id in freemarker [SPR-7710] #12366

@spring-projects-issues

Description

@spring-projects-issues

Pablo opened SPR-7710 and commented

In freemarker, if I use the formInput macro with an array parameter:

<@spring.formInput "command.values[0]"/>

spring generates a form with an invalid id: 'values[0]'

This is related to https://jira.springframework.org/browse/SPR-2380, which was the same bug but with jsp. It is possible that the same happens with velocity.

To fix it in freemarker, you can change, in spring.ftl:

160c160
< <input type="${fieldType}" id="${status.expression}" name="${status.expression}" value="<#if fieldType!="password">${stringStatusValue}</#if>" ${attributes}<@closeTag/>

<input type="${fieldType}" id='${status.expression?replace("[", "")?replace("]", "")}' name="${status.expression}" value="<#if fieldType!="password">${stringStatusValue}</#if>" ${attributes}<@closeTag/>

This change replaces the [ and ] with _.

I am currently using spring 2.5, so it would be nice to have it backported, if possible.

thanks a lot.


Affects: 2.0.8, 2.5 RC1, 2.5 RC2, 2.5 final, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.5.6, 3.0 M1, 3.0 M2, 3.0 M3, 3.0 M4, 3.0 RC1, 3.0 RC2, 3.0 RC3, 3.0 GA, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5

Issue Links:

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