-1

Having a Grails/GSP issue. I want to horizontally align elements within a g:form tag.

My code looks like this currently, though the submitButton is still below the textField.

    <g:form controller="objectSearch" action="search" >
        <g:textField name="searchText" value="${searchText}"  />
        <g:submitButton name="search" value="Search" />         
    </g:form>

Thanks

UPDATE:

I've managed to get the desired result by creating a table within the form, and putting elements within the same <tr> tag (see code below). Surely there is a better way to do this?

<g:form controller="objectSearch" action="search" >
    <table>
        <tr>
            <td>
                <g:textField name="searchText" value="${searchText}"  />
            </td>
            <td>
                <g:submitButton name="search" value="Search" />     
            </td>
        </tr>
    </table>        
</g:form>
Calabria
  • 94
  • 10
  • This has nothing to do with grails, check your css . Also I dont recommend using table for form. – dsharew May 04 '15 at 09:02
  • g:form is translated to a form tag. g:textField and g:submitButton are translated to input tag. Then, it is just a CSS question. (Tip: you are looking for css float attribute) – Fernando May 04 '15 at 11:36
  • Thanks guys, with your hints I was able to fix the problem :) – Calabria May 05 '15 at 06:03

1 Answers1

1

Thanks to the comments from codehx and Fernando, I ended up fixing my problem by including the float attribute of my form elements. See code below:

        <g:form controller="objectSearch" action="search" >
                    <g:textField name="searchText" value="${searchText}"  style="float: left;" />
                    <g:submitButton name="search" value="Search" style="float: right;" />       
        </g:form>
Calabria
  • 94
  • 10