Commit 63fd649571ffa2d957d9dfa463e8f1f1f1d60baa
1 parent
fd40a9e1
-Cabinet started
Showing
3 changed files
with
45 additions
and
3 deletions
Show diff stats
migrations/m170511_102711_add_color_column_to_label_table.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | + use yii\db\Migration; | |
| 4 | + | |
| 5 | + /** | |
| 6 | + * Handles adding color to table `label`. | |
| 7 | + */ | |
| 8 | + class m170511_102711_add_color_column_to_label_table extends Migration | |
| 9 | + { | |
| 10 | + /** | |
| 11 | + * @inheritdoc | |
| 12 | + */ | |
| 13 | + public function up() | |
| 14 | + { | |
| 15 | + $this->addColumn('label', 'color', $this->string()); | |
| 16 | + } | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * @inheritdoc | |
| 20 | + */ | |
| 21 | + public function down() | |
| 22 | + { | |
| 23 | + $this->dropColumn('label', 'color'); | |
| 24 | + } | |
| 25 | + } | ... | ... |
models/Label.php
| ... | ... | @@ -16,10 +16,11 @@ |
| 16 | 16 | * @property integer $sort |
| 17 | 17 | * @property string $value |
| 18 | 18 | * @property boolean $status |
| 19 | + * @property string $color | |
| 19 | 20 | * @property LabelLang[] $labelLangs |
| 20 | 21 | * @property Language[] $languages |
| 21 | 22 | * @property Order[] $orders |
| 22 | - * * From language behavior * | |
| 23 | + * * From language behavior * | |
| 23 | 24 | * @property LabelLang $lang |
| 24 | 25 | * @property LabelLang[] $langs |
| 25 | 26 | * @property LabelLang $objectLang |
| ... | ... | @@ -40,7 +41,7 @@ |
| 40 | 41 | * @method bool getTransactionStatus() |
| 41 | 42 | * @method bool loadWithLangs( Request $request ) |
| 42 | 43 | * @method bool saveWithLangs() |
| 43 | - * * End language behavior * | |
| 44 | + * * End language behavior * | |
| 44 | 45 | * @see LanguageBehavior |
| 45 | 46 | */ |
| 46 | 47 | class Label extends ActiveRecord |
| ... | ... | @@ -76,6 +77,10 @@ |
| 76 | 77 | 'integer', |
| 77 | 78 | ], |
| 78 | 79 | [ |
| 80 | + [ 'color' ], | |
| 81 | + 'string', | |
| 82 | + ], | |
| 83 | + [ | |
| 79 | 84 | [ 'value' ], |
| 80 | 85 | 'number', |
| 81 | 86 | ], |
| ... | ... | @@ -96,6 +101,7 @@ |
| 96 | 101 | 'sort' => Yii::t('order', 'Sort'), |
| 97 | 102 | 'value' => Yii::t('order', 'Value'), |
| 98 | 103 | 'status' => Yii::t('order', 'Status'), |
| 104 | + 'color' => Yii::t('order', 'Color'), | |
| 99 | 105 | ]; |
| 100 | 106 | } |
| 101 | 107 | |
| ... | ... | @@ -113,7 +119,7 @@ |
| 113 | 119 | public function getLanguages() |
| 114 | 120 | { |
| 115 | 121 | return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) |
| 116 | - ->viaTable('label_lang', [ 'label_id' => 'id' ]); | |
| 122 | + ->viaTable('label_lang', [ 'label_id' => 'id' ]); | |
| 117 | 123 | } |
| 118 | 124 | |
| 119 | 125 | /** | ... | ... |
views/label/_form.php
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | use artbox\core\widgets\LanguageForm; |
| 4 | + use kartik\color\ColorInput; | |
| 4 | 5 | use yii\helpers\Html; |
| 5 | 6 | use yii\widgets\ActiveForm; |
| 6 | 7 | |
| ... | ... | @@ -36,6 +37,16 @@ |
| 36 | 37 | 'class' => 'flat', |
| 37 | 38 | ] |
| 38 | 39 | ) ?> |
| 40 | + | |
| 41 | + <?php | |
| 42 | + echo $form->field($model, 'color') | |
| 43 | + ->widget( | |
| 44 | + ColorInput::classname(), | |
| 45 | + [ | |
| 46 | + 'options' => [ 'placeholder' => \Yii::t('app', 'Select color ...') ], | |
| 47 | + ] | |
| 48 | + ); | |
| 49 | + ?> | |
| 39 | 50 | |
| 40 | 51 | <div class="form-group"> |
| 41 | 52 | <?= Html::submitButton( | ... | ... |