public function t($column = null, $language_id = null) { if ($language_id == null) { $language_id = Yii::$app->session->get('language_id'); } if ($this->_general_info_translation === null) { if (!($this->_general_info_translation = GeneralInfoTranslation::find()->where(['general_info_id' => $this->id])->andWhere(['language_id' => $language_id])->one())) { if (!($this->_general_info_translation = GeneralInfoTranslation::find()->where(['general_info_id' => $this->id])->andWhere(['language_id' => Language::getDefault()->id])->one())) { if (!($this->_general_info_translation = GeneralInfoTranslation::find()->where(['general_info_id' => $this->id])->orderBy('id asc')->one())) { $this->_general_info_translation = new GeneralInfoTranslation(); } } } } if ($column == null) { return $this->_general_info_translation; } return $this->_general_info_translation->{$column}; }
use yii\web\View; use yii\widgets\ActiveForm; /* @var $this View */ /* @var $model GeneralInfoTranslation2 */ /* @var $form ActiveForm */ ?> <div class="general-info-translation-form"> <?php $form = ActiveForm::begin(); ?> <div class="col-md-6"> <?php echo $form->field($model, 'language_id')->dropDownList(array_diff_key($this->context->languages_idToName, ArrayHelper::map(GeneralInfoTranslation::find()->where(['general_info_id' => $model->general_info_id])->andWhere(['<>', 'id', (int) $model->id])->all(), 'language_id', 'language_id'))); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textarea(['maxlength' => true, 'rows' => 3, 'style' => 'resize:vertical']); ?> <?php // echo $form->field($model, 'search_text')->textInput(['maxlength' => true]) ?> </div> <div class="col-md-6"> <?php echo $form->field($model, 'page_title')->textInput(['maxlength' => true]); ?>