简体   繁体   中英

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.

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

在表单内使用隐藏字段。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM