Пример #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     // set titles
     $this->setCreateTitle(Yii::t('kalibao.backend', 'message_message_create_title'));
     $this->setUpdateTitle(Yii::t('kalibao.backend', 'message_message_update_title'));
     // models
     $models = $this->getModels();
     // language
     $language = $this->getLanguage();
     // get drop down list methods
     $dropDownList = $this->getDropDownList();
     // set items
     $items = [];
     $items[] = new InputField(['model' => $models['main'], 'attribute' => 'message_group_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'message_group_i18n.title']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-add-action' => Url::to('/message/message-group/create'), 'data-update-action' => Url::to('/message/message-group/update'), 'data-update-argument' => 'id', 'data-related-field' => '.link_message_group_title', 'data-text' => !empty($models['main']->message_group_id) ? MessageGroupI18n::findOne(['message_group_id' => $models['main']->message_group_id, 'i18n_id' => $language])->title : '']]);
     $items[] = new InputField(['model' => $models['main'], 'attribute' => 'source', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('source')]]);
     $models['i18ns'] = $this->orderLanguage($models['i18ns']);
     foreach ($models['i18ns'] as $languageId => $model) {
         $items[] = new InputField(['model' => $model, 'attribute' => 'translation', 'type' => 'activeTextarea', 'label' => Html::labelI18n($languageId), 'options' => ['class' => 'form-control input-sm', 'placeholder' => $models['main']->getAttributeLabel('translation'), 'maxlength' => true, 'name' => (new \ReflectionClass($model))->getShortName() . '[' . $languageId . '][translation]']]);
     }
     $this->setItems($items);
 }
Пример #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMessageGroupI18ns()
 {
     return $this->hasMany(MessageGroupI18n::className(), ['message_group_id' => 'id']);
 }