diff --git a/backend/views/specialization/_form.php b/backend/views/specialization/_form.php index a94b978..88ed501 100755 --- a/backend/views/specialization/_form.php +++ b/backend/views/specialization/_form.php @@ -14,15 +14,24 @@ use yii\helpers\ArrayHelper; field($model, 'specialization_pid')->dropDownList(ArrayHelper::map($model->find()->all(), 'specialization_id', 'specialization_name'), ['prompt' => 'Выберие родителя']) ?> field($model, 'specialization_name')->textInput(['maxlength' => true]) ?> - $model, - 'field'=>'img', - 'width'=>240, - 'height'=>160, - 'multi'=>false, - 'gallery' =>$model->img, - 'name' => 'Загрузить картинку' - ]); ?> + + field($model, 'background')->textInput(); + + if($model->specialization_pid == 0 && !empty($model->specialization_id) ){ + echo \common\widgets\ImageUploader::widget([ + 'model'=> $model, + 'field'=>'image', + 'width'=>940, + 'height'=>324, + 'multi'=>false, + 'gallery' =>$model->image, + 'name' => 'Загрузить картинку' + ]); + } + ?> +
isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
diff --git a/common/models/Specialization.php b/common/models/Specialization.php index ef25514..1c94e8d 100755 --- a/common/models/Specialization.php +++ b/common/models/Specialization.php @@ -10,10 +10,11 @@ use Yii; * @property integer $specialization_id * @property integer $specialization_pid * @property string $specialization_name + * @property string $image + * @property string $background */ class Specialization extends \yii\db\ActiveRecord { - public $img; /** * @inheritdoc */ @@ -28,10 +29,10 @@ class Specialization extends \yii\db\ActiveRecord public function rules() { return [ - [['specialization_pid'], 'integer'], + [['specialization_pid','status'], 'integer'], [['specialization_pid'], 'default', 'value' => '0',], [['specialization_name'], 'required'], - [['specialization_name'], 'string', 'max' => 255], + [['specialization_name','image','background'], 'string', 'max' => 255], ]; } @@ -45,6 +46,9 @@ class Specialization extends \yii\db\ActiveRecord 'specialization_pid' => 'Specialization Pid', 'specialization_name' => 'Specialization Name', 'specialization_parent_name' => 'Specialization Parent Name', + 'image' => 'Картинка', + 'background' => 'Background', + 'status' => 'Status', ]; } @@ -54,4 +58,9 @@ class Specialization extends \yii\db\ActiveRecord return $this->hasOne(self::className(), ['specialization_id' => 'specialization_pid']); } + public function getChildren() + { + return $this->hasMany(self::className(), ['specialization_pid' => 'specialization_id']); + } + } diff --git a/common/widgets/FieldEditor.php b/common/widgets/FieldEditor.php index b939584..6fe7066 100755 --- a/common/widgets/FieldEditor.php +++ b/common/widgets/FieldEditor.php @@ -33,6 +33,7 @@ class FieldEditor extends Widget protected function findModel() { + if (($model = Fields::find()->where([ 'table_id'=>$this->item_id, 'table_name'=>$this->model, diff --git a/common/widgets/views/education_field.php b/common/widgets/views/education_field.php index e8eca71..6c501ef 100755 --- a/common/widgets/views/education_field.php +++ b/common/widgets/views/education_field.php @@ -1,5 +1,6 @@
@@ -8,16 +9,18 @@ use yii\helpers\Html;

Добавить поле

- 'form-group','id'=>isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ])?> - - - + + + + @@ -30,7 +33,7 @@ use yii\helpers\Html; var block = $(this).parent('fieldset'); var block_id = $(this).parent('fieldset'); var sub_block = '
'+ - ''+ + ''+ ''+ ''+ ''+ diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index b3b1772..c0bb5e4 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -48,11 +48,10 @@ class AccountsController extends Controller $langs = Language::getActiveLanguages(); - if ($user->load(Yii::$app->request->post()) && $user->save()) { $user->userInfo->load(Yii::$app->request->post()); $user->userInfo->save(); - Fields::saveFieldData( Yii::$app->request->post('Fields'), $user->id, $user::className()); + Fields::saveFieldData( Yii::$app->request->post('Fields'), $user->id, $user::className(),'ru'); return $this->render('cabinet', [ 'user' => $user, 'user_info' => $user->userInfo, diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 3181348..c97ed0e 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -1,6 +1,7 @@ render('index'); + $specializations = Specialization::find()->where(['specialization_pid'=>0])->all(); + + return $this->render('index',[ + 'specializations' => $specializations, + ]); } /** diff --git a/frontend/views/accounts/_form.php b/frontend/views/accounts/_form.php index 2ee6892..ec61b8c 100755 --- a/frontend/views/accounts/_form.php +++ b/frontend/views/accounts/_form.php @@ -56,7 +56,7 @@ use mihaildev\elfinder\ElFinder; 'template'=>'education', 'item_id'=> $user->id, 'model'=>'common\models\User', - 'language'=>'0' + 'language'=>'ru' ]); ?> diff --git a/frontend/views/site/index.php b/frontend/views/site/index.php index da4a682..0a35809 100755 --- a/frontend/views/site/index.php +++ b/frontend/views/site/index.php @@ -1,8 +1,11 @@ title = 'My Yii Application'; ?> @@ -49,83 +52,29 @@ $this->title = 'My Yii Application';
-- libgit2 0.21.4