Search code examples
grailsviewcontrolleractiongsp

Get remoteField name in Grails controller action


I have a Grails gsp view with a remoteField. The remoteField calls a controller action. In the controller action I would like to know the name of the remoteField that invoked the controller action.

Thank you, Francesco


Solution

  • Just add an attribute like name or id to your remoteField tag and in your controller you will access it through the params.

        <g:remoteField id="myId" controller="book" action="changeTitle" update="titleDiv"  
        name="title"    value="${book?.name}" />
    

    in controller

      def changeTitle() {
         println params.id
      }