Example #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     // set titles
     $this->setCreateTitle(Yii::t('kalibao.backend', 'cms_news_create_title'));
     $this->setUpdateTitle(Yii::t('kalibao.backend', 'cms_news_update_title'));
     // models
     $models = $this->getModels();
     // language
     $language = $this->getLanguage();
     // get drop down list methods
     $dropDownList = $this->getDropDownList();
     // upload config
     $uploadConfig['main'] = $this->uploadConfig[(new \ReflectionClass($models['main']))->getName()];
     // set items
     $items = [];
     if (!$models['main']->isNewRecord) {
         $items[] = new SimpleValueField(['model' => $models['main'], 'attribute' => 'id', 'value' => $models['main']->id]);
     }
     $items[] = new InputField(['model' => $models['i18n'], 'attribute' => 'title', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('title')]]);
     $items[] = new InputField(['model' => $models['main'], 'attribute' => 'cms_news_group_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'cms_news_group_i18n.title']), 'data-add-action' => Url::to('/cms/cms-news-group/create'), 'data-update-action' => Url::to('/cms/cms-news-group/update'), 'data-update-argument' => 'id', 'data-related-field' => '.link_cms_news_group_title', 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($models['main']->cms_news_group_id) ? CmsNewsGroupI18n::findOne(['cms_news_group_id' => $models['main']->cms_news_group_id, 'i18n_id' => $language])->title : '']]);
     $items[] = new InputField(['model' => $models['i18n'], 'attribute' => 'content', 'type' => 'activeTextarea', 'options' => ['class' => 'form-control input-sm wysiwyg-textarea', 'data-ckeditor-filebrowser-browse-url' => Url::to(['cms-image/list', 'mode' => 'explorer']), 'data-ckeditor-language' => $language]]);
     $items[] = new InputField(['model' => $models['main'], 'attribute' => 'activated', 'type' => 'activeCheckbox', 'options' => ['class' => '', 'label' => '']]);
     $items[] = new InputField(['model' => $models['main'], 'attribute' => 'published_at', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm date-picker date-range', 'value' => $models['main']->published_at != '' ? Yii::$app->formatter->asDatetime($models['main']->published_at, 'yyyy-MM-dd') : '', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('published_at')]]);
     if (!$models['main']->isNewRecord) {
         $items[] = new SimpleValueField(['model' => $models['main'], 'attribute' => 'created_at', 'value' => Yii::$app->formatter->asDatetime($models['main']->created_at, I18N::getDateFormat())]);
     }
     if (!$models['main']->isNewRecord) {
         $items[] = new SimpleValueField(['model' => $models['main'], 'attribute' => 'updated_at', 'value' => Yii::$app->formatter->asDatetime($models['main']->updated_at, I18N::getDateFormat())]);
     }
     $this->setItems($items);
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCmsNewsGroupI18ns()
 {
     return $this->hasMany(CmsNewsGroupI18n::className(), ['cms_news_group_id' => 'cms_news_group_id']);
 }