Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding id field to HTML end result of a GSP <g:form> tag

Tags:

html

grails

gsp

Im creating a GSP form that i wish to submit using the $.ajax() call.

I understand that the GSPs get rendered into the final HTML that is seen by the browser, and thus javascript can call normal HTML elements.

my form is created as such:

<g:form action="save" id="callmeForm" >
  <fieldset class="form">
    <g:render template="form"/>
  </fieldset>
  <fieldset class="buttons">
    <g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" />
  </fieldset>
</g:form>

but when the final form is rendered in HTML, it lacks the id field i gave in the tag:

<form action="/racetrack/callback/save/callmeForm" method="post" >
  <fieldset class="form">
    etc...

Is there a way I can get the id property to carry thru so i can reference the form by its id with javascript?

like image 764
Dave Anderson Avatar asked Jan 16 '12 08:01

Dave Anderson


1 Answers

You can use name attribute which sets both the form tag's name and id attributes to the same value.

like image 71
Lauri Piispanen Avatar answered Nov 10 '22 03:11

Lauri Piispanen