I have a form in a gsp page and this form has a g: textField that the user will enter values and then click a button to filter the grid values.
For example: there are 3 records in the grid ... Joaozinho, Jose, Maria. If the user type Joaozinho and click send, it should only appear the results equivalent to Joaozinho.
My form is falling on the controller, but it is not working. I'm using namedQuery in the domain class and I believe I'm passing parameters in the wrong way.
My form code:
<g:form url="[action:'searchByFilter']" method="GET">
<p>Filtro de busca</p>
<g:textField name="search" params="[search : search]"/>
<g:submitButton name="search" class="input-search"
value="${message(code: 'default.button.search.filter')}" />
</g:form>
Code of my Domain class:
static namedQueries = {
getInvoicesByFilter {
eq 'description', 'search'
}
}
The search attribute is the value that was typed in the form input.
Controller code:
def searchByFilter(Invoice invoiceInstance){
respond Invoice.getInvoicesByFilter.list(params), view: "index"
}
When I click the search button on the form, it is not returning any value, but it should bring, since I have the registry in the database.
What should I do to fix this?