Commit ca752a64 by Kai Mindermann Committed by Alexander Makarov

Fixes #4410: Fixed Gii to preserve database column order in generated _form.php

parent 86d48ca9
......@@ -8,6 +8,7 @@ Yii Framework 2 gii extension Change Log
- Bug #2314: Gii model generator does not generate correct relation type in some special case (qiangxue)
- Bug #3265: Fixed incorrect controller class name validation (suralc)
- Bug #3693: Fixed broken Gii preview when a file is unchanged (cebe)
- Bug #4410: Fixed Gii to preserve database column order in generated _form.php (kmindi)
- Enh #2018: Search model is not required anymore in CRUD generator (johonunu)
- Enh #3088: The gii module will manage their own URL rules now (qiangxue)
- Enh #3222: Added `useTablePrefix` option to the model generator for Gii (horizons2)
......
......@@ -28,8 +28,10 @@ use yii\widgets\ActiveForm;
<?= "<?php " ?>$form = ActiveForm::begin(); ?>
<?php foreach ($safeAttributes as $attribute) {
echo " <?= " . $generator->generateActiveField($attribute) . " ?>\n\n";
<?php foreach ($generator->getColumnNames() as $attribute) {
if (in_array($attribute, $safeAttributes)) {
echo " <?= " . $generator->generateActiveField($attribute) . " ?>\n\n";
}
} ?>
<div class="form-group">
<?= "<?= " ?>Html::submitButton($model->isNewRecord ? <?= $generator->generateString('Create') ?> : <?= $generator->generateString('Update') ?>, ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment