Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Component/s: TagLib
    • Labels:
    • Environment:
      WinXP on Intel

      Description

      The g:form tag supports the attributes name and id.

      But name is not XHTML strict compatibel, so it should not be used further.

      The id attribute is used to create the submit url of the form. It has nothing to do with the usual css id attribute. But it prevents the usage of it. CSS id can be set only indirectly via the name attribute -> which will break xhtml compatibility.

      So currently it is not possible to produce a xhtml strict compatibel form with and id attribute to customize via CSS and use in DOM operations.

      Suggestion: rename the "id" attribute to something else like "objectId" or "instanceId" so "id" can be used for CSS / DOM.

      The same id-stuff (don't now about xhtml strict compatibility) for other TAGs like:
      -createLink
      -link
      -remoteXXX
      -uploadForm

        Activity

        Hide
        Marius Seritan added a comment -

        It may be complicated to re-purpose the id attribute of g:form. We could use a new attribute name for the dom id, for example dom_id.

        Marius

        Show
        Marius Seritan added a comment - It may be complicated to re-purpose the id attribute of g:form. We could use a new attribute name for the dom id, for example dom_id. Marius
        Hide
        Fernando added a comment -

        A workaround is to use a html form tag (instead of g:form) and create the action attribute using createLink.

        For example:
        <form method="get" id="myDesiredId" action="$

        {createLink(controller: 'controllerName', action: 'actionName', id: 'IdParameter')}

        ">
        rendering something like <form method="get" id="myDesiredId" action="controllerName/actionName/IdParameter">

        Anyway, I would preferred a solution by now.

        Show
        Fernando added a comment - A workaround is to use a html form tag (instead of g:form) and create the action attribute using createLink. For example: <form method="get" id="myDesiredId" action="$ {createLink(controller: 'controllerName', action: 'actionName', id: 'IdParameter')} "> rendering something like <form method="get" id="myDesiredId" action="controllerName/actionName/IdParameter"> Anyway, I would preferred a solution by now.
        Hide
        Jan Schumacher added a comment - - edited

        Hi!

        There's an other workaround for this issue.

        You can use the url attribute of the g:form tag.

        For example:

         
        <g:form id="exampleForm" url="[controller:'example', action:'doSomething', id='importantStuff']">
        <!-- Do something -->
        </g:form>
        

        Rendering something like this:

        <form method="get" id="exampleForm" action="example/doSomething/importantStuff">
        <!-- Do something -->
        </form>
        

        Best regards

        Jan Schumacher

        Show
        Jan Schumacher added a comment - - edited Hi! There's an other workaround for this issue. You can use the url attribute of the g:form tag. For example: <g:form id= "exampleForm" url= "[controller:'example', action:'doSomething', id='importantStuff']" > <!-- Do something --> </g:form> Rendering something like this: <form method= "get" id= "exampleForm" action= "example/doSomething/importantStuff" > <!-- Do something --> </form> Best regards Jan Schumacher
        Hide
        Bobby Warner added a comment -

        The name attribute on the form tag is valid in HTML5 – http://www.w3.org/TR/html5/forms.html#the-form-element

        I recommend closing this issue unless I'm missing something. Thanks, Bobby

        Show
        Bobby Warner added a comment - The name attribute on the form tag is valid in HTML5 – http://www.w3.org/TR/html5/forms.html#the-form-element I recommend closing this issue unless I'm missing something. Thanks, Bobby
        Hide
        Peter Ledbrook added a comment -

        Thanks Bobby. I think it's a reasonable request to add support for something like an "idParam" or "domId" attribute which behaves the same way as an 'id' param in the "url" attribute. But as Jan pointed out, there is a quite reasonable workaround so I'm lowering the priority. I'll also mark it as something suitable for the community to contribute.

        If anyone is interested in implementing this, the relevant code is here: https://github.com/grails/grails-core/blob/master/grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/ApplicationTagLib.groovy#L323

        Show
        Peter Ledbrook added a comment - Thanks Bobby. I think it's a reasonable request to add support for something like an "idParam" or "domId" attribute which behaves the same way as an 'id' param in the "url" attribute. But as Jan pointed out, there is a quite reasonable workaround so I'm lowering the priority. I'll also mark it as something suitable for the community to contribute. If anyone is interested in implementing this, the relevant code is here: https://github.com/grails/grails-core/blob/master/grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/ApplicationTagLib.groovy#L323

          People

          • Assignee:
            Unassigned
            Reporter:
            Horst Krause
          • Votes:
            4 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development