<td> <button type="button" class="del-db-foreign-key btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button> </td> <td> <div class="col-md-5"> <?php echo $form->field($foreignKey, "[{$i}]table")->textInput(['maxlength' => true]); ?> <?php echo $form->field($foreignKey, "[{$i}]columns")->textInput(['maxlength' => true]); ?> </div> <div class="col-md-5"> <?php echo $form->field($foreignKey, "[{$i}]refTable")->textInput(['maxlength' => true]); ?> <?php echo $form->field($foreignKey, "[{$i}]refColumns")->textInput(['maxlength' => true]); ?> </div> <div class="col-md-2"> <?php echo $form->field($foreignKey, "[{$i}]delete")->dropDownList(['' => ''] + ForeignKey::constraintOptions()); ?> <?php echo $form->field($foreignKey, "[{$i}]update")->dropDownList(['' => ''] + ForeignKey::constraintOptions()); ?> </div> </td> </tr>
/** * @inheritdoc */ public function load($data, $formName = null) { if (!parent::load($data, $formName)) { return false; } $this->migrationName = preg_replace('/\\s+/', '_', $this->migrationName); $dataFix = ['Table' => [], 'Column' => []]; if (isset($data['Table'])) { foreach ($data['Table'] as $temp) { $dataFix['Table'][] = $temp; } } if (isset($data['Column'])) { foreach ($data['Column'] as $temp) { $columnFix = []; foreach ($temp as $colTemp) { $columnFix[] = $colTemp; } $temp = $columnFix; $dataFix['Column'][] = $temp; } } if (isset($data['Index'])) { foreach ($data['Index'] as $temp) { $dataFix['Index'][] = $temp; } } if (isset($data['ForeignKey'])) { foreach ($data['ForeignKey'] as $temp) { $dataFix['ForeignKey'][] = $temp; } } $data = $dataFix; if (isset($data['Table'])) { $this->tables = static::createMultiple(Table::className(), [], $data); Table::loadMultiple($this->tables, $data); $loadData = []; for ($i = 0; $i < count($this->tables); ++$i) { $loadData['Column'] = $data['Column'][$i]; $this->tables[$i]->columns = static::createMultiple(Column::className(), [], $loadData); $this->tables[$i]->isNewRecord = false; Column::loadMultiple($this->tables[$i]->columns, $loadData); } } else { $this->tables = [new Table()]; } if (isset($data['Index'])) { $this->indices = static::createMultiple(Index::className(), [], $data); Index::loadMultiple($this->indices, $data); foreach ($this->indices as $index) { $index->isNewRecord = false; } } else { $this->indices = [new Index()]; } if (isset($data['ForeignKey'])) { $this->foreignKeys = static::createMultiple(ForeignKey::className(), [], $data); ForeignKey::loadMultiple($this->foreignKeys, $data); foreach ($this->foreignKeys as $fKey) { $fKey->isNewRecord = false; } } else { $this->foreignKeys = [new ForeignKey()]; } return true; }