title: Is there a way in Geb to automatically assign the right Module to all Elements in a Form
body: <p>We use Geb to run our Frontend Tests and we have some quite complex pages in our application.</p>
  
  <p>Some of the pages have forms with a lot of different buttons, checkboxes and some multiselects.</p>
  
  <p>I love the feature of geb/groovy that i just have to define the form in the Page Object and then can access all its elements in it.</p>
  
  <pre><code>static content = {
      form { $("#form")}
  }
  </code></pre>
  
  <p>But for them to be clickable and to query if they are readonly and more they need to be at least of type FormElement which does not happen with the above method. So I have to mention all these FormElements separately:</p>
  
  <pre><code>static content = {
      form { $("#form")}
      button1 { $("#button1").module(FormElement)}
      button2 { $("#button2").module(FormElement)}
      checkbox{ $("#checkbox").module(Checkbox)}
      ...
  }
  </code></pre>
  
  <p>All those buttons, checkboxes... are already in the form variable, but cannot be clicked or checked if they are selected and so on. It's also not possible to apply the the module afterwards like this:</p>
  
  <pre><code>def "test something"() {
      when:
          form.button1.module(FormElement).click() //error
      then:
          ...
  }
  </code></pre>
  
  <p>Is there no way to automatically assign each input, checkbox, radiobutton, button,... the correct Module based on their type without the need of doing it by hand? </p>
  
  <p>If someone could also point me in the right direction to understand how this "form { $("#form")}" works, that i can access all sub elements by its name by just suppying the form, that would be nice!</p>