title: How to handle complex form with multiple models and tabular input in yii
body: <p>I've read a lot of documentation about how to handle models and forms in yii and I've found a solution that works for the case that I explain following, but the problem is that the code is complex to write and to maintain, so I'm looking for suggestions.</p>
  
  <p>The case is the following: I need to save together two different models and a third model that is a tabular input (more instances of the same model).</p>
  
  <p>For instance, I may want to save a Blog post (first model) with the author information (second model) and a list of references (third model, the tabular one).</p>
  
  <p>I'd like to validate all of them via ajax in one step and save them transactionally.</p>
  
  <p>I've read all of these link.</p>
  
  <p><a href="http://www.yiiframework.com/wiki/559/tabular-input-validating-and-saving-related-models/" rel="nofollow noreferrer">http://www.yiiframework.com/wiki/559/tabular-input-validating-and-saving-related-models/</a></p>
  
  <p><a href="https://stackoverflow.com/questions/6720209/multi-model-forms-in-yii">multi model forms in yii</a></p>
  
  <p><a href="http://www.yiiframework.com/wiki/19/how-to-use-a-single-form-to-collect-data-for-two-or-more-models/" rel="nofollow noreferrer">http://www.yiiframework.com/wiki/19/how-to-use-a-single-form-to-collect-data-for-two-or-more-models/</a></p>
  
  <p><a href="http://www.yiiframework.com/wiki/218/how-to-use-single-form-to-collect-data-for-two-or-more-models-cactiveform-and-ajax-validation-edition/" rel="nofollow noreferrer">http://www.yiiframework.com/wiki/218/how-to-use-single-form-to-collect-data-for-two-or-more-models-cactiveform-and-ajax-validation-edition/</a></p>
  
  <p><a href="http://www.yiiframework.com/doc/guide/1.1/en/form.table" rel="nofollow noreferrer">http://www.yiiframework.com/doc/guide/1.1/en/form.table</a></p>
  
  <p><a href="http://www.yiiframework.com/wiki/362/how-to-use-multiple-instances-of-the-same-model-in-the-same-form/" rel="nofollow noreferrer">http://www.yiiframework.com/wiki/362/how-to-use-multiple-instances-of-the-same-model-in-the-same-form/</a></p>
  
  <p><a href="http://www.yiiframework.com/forum/index.php/topic/14082-transaction-on-multiple-ar/" rel="nofollow noreferrer">http://www.yiiframework.com/forum/index.php/topic/14082-transaction-on-multiple-ar/</a></p>
  
  <p><a href="http://www.yiiframework.com/wiki/559/tabular-input-validating-and-saving-related-models/" rel="nofollow noreferrer">http://www.yiiframework.com/wiki/559/tabular-input-validating-and-saving-related-models/</a></p>
  
  <p><a href="https://github.com/yiiext/with-related-behavior" rel="nofollow noreferrer">https://github.com/yiiext/with-related-behavior</a></p>
  
  <p>The last link is interesting, but if someone has one best practice to share, I'll be thankful to him.  </p>