Tabular input
In this section, we will show you how to use a model to save and validate related models. Sometimes you will need to handle multiple models of the same kind in a single form.
For instance, we have contests and prizes for contests. Any contest might contain an unlimited number of prizes. So, we need the ability to create a contest with prizes, validate them, display all errors, and save the primary model (contest model) and all related models (prize models) to the database.
Getting ready
Create a new application by using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
Create migrations for contest and prize tables with the following commands:
./yii migrate/create create_table_contest_and_prize_table Update just created migration's methods up() and down() by following code public function up() { $tableOptions = null; if ($this->db->driverName === 'mysql') { $tableOptions =...