prefix attribute is ignored
Maybe I'm misunderstanding something, but when the following field is rendered
<f:field property="name" label="Name" prefix="foo.">
<g:textField name="${property}" value="${value}" class="input-xlarge" maxlength="191"/>
</f:field>
The name of the input is "name", shouldn't it be "foo.name"?
That's the idea, yeah. Looks like a bug. Is it only when you use a body like that?
No, the prefix is also ignored even when there's no body, e.g.
<f:field bean="beanInstance" property="name" label="Name" prefix="foo."/>
Just ran into your first problem myself. You might just need to specify the prefix explicitly in the body:
<f:field property="name" label="Name" prefix="foo.">
<g:textField name="${prefix}${property}" value="${value}" class="input-xlarge" maxlength="191"/>
</f:field>
That's mentioned under Customized Field Rendering (https://grails-fields-plugin.github.io/grails-fields/guide/single.html#customizingFieldRendering) in the docs--see the "Template Parameters" section.
Not sure about the second issue, though, or if they're related, in your case.
Just like tsweetser mentions, the docs do say that including the prefix in a custom template is a manual proces: prefix: "A string (including the trailing period) that should be appended before the input name such as name="${prefix}propertyName". The label is also modified."
I've just made a demo project, Grails 2.4.3, and it works fine, including the prefix.
@domurtag: Are you sure you don't have a custom template like: grails-app/views/_fields/default/_field.gsp That does not include the prefix variable?
I cannot reproduce this problem.
If the documentation is wrong, please make a pull request on that too. Thanks!
sbglasius: I think the documentation (and behavior of the plugin) is correct. It makes sence that you have both the prefix and the propertyName available, and not by default concatenated.
@JacobAae You're right my _field.gsp template looks like this:
<div class="fieldColumn">
<%=widget%>
</div>
So it seems that as things currently stand I need to specify a body if I want to use a prefix, e.g.
<f:field property="name" prefix="foo.">
<g:textField name="${prefix}${property}" value="${value}" />
</f:field>
Obviously it would be preferable if I could do this instead
<f:field property="name" prefix="foo."/>
But if the docs say that I need to provide a body, then I guess I'm proposing an improvement rather than reporting a bug. I've changed the labels to reflect this.