title: Grails: Dynamic form
body: <p>I have problem with <strong>remove Author from Book</strong>.</p>
  
  <p>I have class Book and class Author in <strong>One-To-Many unidirectional</strong> relationship:</p>
  
  <pre><code>class Book{
  
      String isbn
      ...
  
      List&lt;Author&gt; authors
      static hasMany = [ authors: Author ]
  }
  
  class Author {
  
      String firstname
      String lastname
      ...
  
  }
  </code></pre>
  
  <p>note: in class Author there is not <strong>belongTo</strong>.</p>
  
  <p>I use dynamic form:
  <img src="https://i.stack.imgur.com/BsPVF.png" alt="enter image description here"></p>
  
  <p>Please note buttons <strong>Add author</strong> and <strong>Remove author</strong>. I use JavaScript for append html code to form or remove html code from form.</p>
  
  <p>After that I save class Book in controller:  </p>
  
  <pre><code> def save = {
              def book = new Book()
  
              if (params.id){
                  book = Book.get(params.id)                     
              }
  
              book.properties = params
  
              if( book.save() ){
                  redirect(controller:"book", action:"all")
                  return
              }else{
                  render(view:'form', model:["book": book])
                  return
              }
          }
  </code></pre>
  
  <p><strong>It work well</strong> for <strong>Add author</strong> and for <strong>editing author</strong> but <strong>not for Remove author</strong>.
  If I used Remove author button and click submit form, the <strong>author does not remove from Book</strong>.
  There are all the authors as before the editing.</p>
  
  <p>Please, can You help my with this problem? 
  It is a good solution to this problem?</p>
  
  <p>Thank a lot
  Tom</p>