/** * @inheritdoc */ public function init() { parent::init(); // get model $model = $this->getModel(); // language $language = $this->getLanguage(); // get drop down list methods $dropDownList = $this->getDropDownList(); // set titles $this->setTitle(Yii::t('kalibao.backend', 'message_message_list_title')); $gridHeadAttributes = ['source' => true, 'message_group_i18n_title' => true]; $languageLabels = []; foreach ($this->languageGroupLanguages as $language) { if (isset($language->languageI18ns[0])) { $languageLabels[$language->language_id] = Html::labelI18n($language->language_id); } } $headFilters = [new InputField(['model' => $model, 'attribute' => 'source', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, '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-text' => !empty($model->message_group_id) ? $this->messageGroups[$model->message_group_id]->name : '']])]; $advancedHeadFilters = [new InputField(['model' => $model, 'attribute' => 'id', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, 'attribute' => 'source', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, '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-text' => !empty($model->message_group_id) ? $this->messageGroups[$model->message_group_id]->title : '']])]; $languageLabels = $this->orderLanguage($languageLabels); foreach ($languageLabels as $languageId => $attribute) { $gridHeadAttributes[] = $attribute; $headFilters[] = new InputField(['model' => $model, 'attribute' => 'message_i18n_translation[' . $languageId . ']', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search'), 'name' => (new \ReflectionClass($model))->getShortName() . '[message_i18n_translation][' . $languageId . ']']]); $advancedHeadFilters[] = new InputField(['model' => $model, 'attribute' => 'message_i18n_translation[' . $languageId . ']', 'type' => 'activeTextInput', 'label' => Html::labelI18n($languageId), 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search'), 'name' => (new \ReflectionClass($model))->getShortName() . '[message_i18n_translation][' . $languageId . ']']]); } $advancedHeadFilters[] = new DateRangeField(['model' => $model, 'attribute' => 'created_at', 'start' => new InputField(['model' => $model, 'attribute' => 'created_at_start', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']]), 'end' => new InputField(['model' => $model, 'attribute' => 'created_at_end', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']])]); $advancedHeadFilters[] = new DateRangeField(['model' => $model, 'attribute' => 'updated_at', 'start' => new InputField(['model' => $model, 'attribute' => 'updated_at_start', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']]), 'end' => new InputField(['model' => $model, 'attribute' => 'updated_at_end', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']])]); // set head attributes $this->setGridHeadAttributes($gridHeadAttributes); // set head filters $this->setGridHeadFilters($headFilters); // set advanced filters $this->setAdvancedFilters($advancedHeadFilters); }
/** * @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); }
<?php /** * @copyright Copyright (c) 2015 Kévin Walter <*****@*****.**> - Kalibao * @license https://github.com/kalibao/kalibao-framework/blob/master/LICENSE */ use kalibao\common\components\helpers\Html; ?> <thead> <tr class="form-inline"> <th></th> <?php foreach ($crudTranslate->languages as $language) { ?> <th><?php echo Html::labelI18n($language); ?> </th> <?php } ?> </tr> </thead>