Commit a6f07fecc34665e24d2c40a4bcd7780679371f40
1 parent
85414aee
Importers CRUD
Showing
2 changed files
with
59 additions
and
1 deletions
Show diff stats
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "w_currency". | ||
9 | + * | ||
10 | + * @property integer $id | ||
11 | + * @property string $name | ||
12 | + * @property double $rate | ||
13 | + * @property integer $is_default | ||
14 | + * @property string $timestamp | ||
15 | + */ | ||
16 | +class Currency extends \yii\db\ActiveRecord | ||
17 | +{ | ||
18 | + /** | ||
19 | + * @inheritdoc | ||
20 | + */ | ||
21 | + public static function tableName() | ||
22 | + { | ||
23 | + return 'w_currency'; | ||
24 | + } | ||
25 | + | ||
26 | + /** | ||
27 | + * @inheritdoc | ||
28 | + */ | ||
29 | + public function rules() | ||
30 | + { | ||
31 | + return [ | ||
32 | + [['name', 'rate'], 'required'], | ||
33 | + [['rate'], 'number'], | ||
34 | + [['is_default'], 'integer'], | ||
35 | + [['timestamp'], 'safe'], | ||
36 | + [['name'], 'string', 'max' => 50], | ||
37 | + [['name'], 'unique'], | ||
38 | + [['is_default'], 'unique'] | ||
39 | + ]; | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * @inheritdoc | ||
44 | + */ | ||
45 | + public function attributeLabels() | ||
46 | + { | ||
47 | + return [ | ||
48 | + 'id' => 'ID', | ||
49 | + 'name' => 'Name', | ||
50 | + 'rate' => 'Rate', | ||
51 | + 'is_default' => 'Is Default', | ||
52 | + 'timestamp' => 'Timestamp', | ||
53 | + ]; | ||
54 | + } | ||
55 | +} |
backend/views/importers/_form.php
@@ -2,6 +2,8 @@ | @@ -2,6 +2,8 @@ | ||
2 | 2 | ||
3 | use yii\helpers\Html; | 3 | use yii\helpers\Html; |
4 | use yii\widgets\ActiveForm; | 4 | use yii\widgets\ActiveForm; |
5 | +use yii\helpers\ArrayHelper; | ||
6 | +use backend\models\Currency; | ||
5 | 7 | ||
6 | /* @var $this yii\web\View */ | 8 | /* @var $this yii\web\View */ |
7 | /* @var $model backend\models\Importers */ | 9 | /* @var $model backend\models\Importers */ |
@@ -38,10 +40,11 @@ use yii\widgets\ActiveForm; | @@ -38,10 +40,11 @@ use yii\widgets\ActiveForm; | ||
38 | 40 | ||
39 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> | 41 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> |
40 | 42 | ||
41 | - <?= $form->field($model, 'active')->textInput() ?> | 43 | + <?= $form->field($model, 'active')->checkbox() ?> |
42 | 44 | ||
43 | <?= $form->field($model, 'name_price')->textInput(['maxlength' => true]) ?> | 45 | <?= $form->field($model, 'name_price')->textInput(['maxlength' => true]) ?> |
44 | 46 | ||
47 | + <?= $form->field($model, 'city')->dropDownList(ArrayHelper::map(Currency::find()->all(), 'id', 'name'), ['prompt' => 'Выберие город']) ?> | ||
45 | <?= $form->field($model, 'currency_id')->textInput() ?> | 48 | <?= $form->field($model, 'currency_id')->textInput() ?> |
46 | 49 | ||
47 | <?= $form->field($model, 'delivery')->textInput(['maxlength' => true]) ?> | 50 | <?= $form->field($model, 'delivery')->textInput(['maxlength' => true]) ?> |