user721588
user721588

Reputation:

add groovy code to grails input form

Is it possible to add groovy code to grails form? I have a form:

<g:uploadForm controller="document" action="save" method="post">
    <input type="file" name="dataFile" />
    <input type="submit" id="addDocument" value="<g:message code=messages.document.save"/>">
</g:uploadForm>

I need to add code that puts the URL segments to the parameter value.

Upvotes: 0

Views: 585

Answers (2)

Tiago Farias
Tiago Farias

Reputation: 3407

You're using a POST (because it's an upload and that's correct) method in your form, so you will not see the params in the URL. The params will get there (to the controller you redirect the request to), but won't show at the URL. In any case, you should go with hidden inputs in your form. Like:

<input type="hidden" id="foo" value=""/>

In your controller, you can get the parameters set in your input hidden fields simply by accessing the params map:

params.foo

Upvotes: 1

Sergei Shushkevich
Sergei Shushkevich

Reputation: 1376

Use hidden fields inside the form.

Upvotes: 0

Related Questions