/** * @inheritdoc */ public function init() { parent::init(); // 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 = []; $items[] = new InputField(['model' => $models['main'], 'attribute' => 'third_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'third.id']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($models['main']->third_id) ? Third::findOne(['id' => $models['main']->third_id])->id : '']]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'first_name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('first_name')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'last_name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('last_name')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'email', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('email')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'default_language', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'language_i18n.title']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($models['main']->default_language) ? LanguageI18n::findOne(['language_id' => $models['main']->default_language, 'i18n_id' => $language])->title : '']]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'user_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'user.username']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($models['main']->user_id) ? User::findOne(['id' => $models['main']->user_id])->username : '']]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'gender_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'person_gender_i18n.title']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($models['main']->gender_id) ? PersonGenderI18n::findOne(['gender_id' => $models['main']->gender_id, 'i18n_id' => $language])->title : '']]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'phone_1', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('phone_1')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'phone_2', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('phone_2')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'fax', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('fax')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'website', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('website')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'birthday', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm date-picker date-range', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('birthday')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'skype', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('skype')]]); $items[] = new SimpleValueField(['model' => $models['main'], 'attribute' => 'created_at', 'value' => Yii::$app->formatter->asDatetime($models['main']->created_at, I18N::getDateFormat())]); $items[] = new SimpleValueField(['model' => $models['main'], 'attribute' => 'updated_at', 'value' => Yii::$app->formatter->asDatetime($models['main']->updated_at, I18N::getDateFormat())]); $this->setItems($items); }
/** * @inheritdoc */ public function init() { parent::init(); // set titles $this->setCreateTitle(Yii::t('kalibao.backend', 'rbac_user_create_title')); $this->setUpdateTitle(Yii::t('kalibao.backend', 'rbac_user_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' => 'third_id', 'value' => $models['main']->third_id]); } $items[] = new InputField(['model' => $models['main'], 'attribute' => 'first_name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('first_name')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'last_name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('last_name')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'email', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('email')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'default_language', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'language_i18n.title']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($models['main']->default_language) ? LanguageI18n::findOne(['language_id' => $models['main']->default_language, 'i18n_id' => $language])->title : '']]); $items[] = new InputField(['model' => $models['user'], 'attribute' => 'password', 'type' => 'activePasswordInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['user']->getAttributeLabel('password')]]); $items[] = new InputField(['model' => $models['user'], 'attribute' => 'password_repeat', 'type' => 'activePasswordInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['user']->getAttributeLabel('password_repeat')]]); $items[] = new InputField(['model' => $models['user'], 'attribute' => 'status', 'type' => 'activeDropDownList', 'data' => $dropDownList('user.status:required'), 'options' => ['class' => 'form-control input-sm']]); $items[] = new InputField(['model' => $models['user'], 'attribute' => 'active_password_reset', 'type' => 'activeCheckbox', 'options' => ['label' => '']]); if (!empty($models['rbacRoles'])) { $rbacRoles = []; foreach ($models['rbacRoles'] as $rbacRole) { $rbacRoles[$rbacRole->id] = $rbacRole->rbacRoleI18ns[0]->title; } $rbacUserRoles = []; foreach ($models['rbacUserRoles'] as $rbacUserRole) { $rbacUserRoles[] = $rbacUserRole->rbac_role_id; } $items[] = new SimpleValueField(['label' => Yii::t('kalibao.backend', 'person_user_roles'), 'value' => Html::checkboxList('rbacUserRolesId', $rbacUserRoles, $rbacRoles, ['unselect' => '-1'])]); } 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); }
/** * @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', 'rbac_user_list_title')); // set head attributes $this->setGridHeadAttributes(['first_name' => true, 'last_name' => true, 'email' => true, 'language_i18n_title' => true, 'user_status' => true]); // set head filters $this->setGridHeadFilters([new InputField(['model' => $model, 'attribute' => 'first_name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, 'attribute' => 'last_name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, 'attribute' => 'email', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, 'attribute' => 'default_language', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'language_i18n.title']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($model->default_language) ? LanguageI18n::findOne(['language_id' => $model->default_language, 'i18n_id' => $language])->title : '']]), new InputField(['model' => $model, 'attribute' => 'user_status', 'type' => 'activeDropDownList', 'data' => $dropDownList('user.status'), 'options' => ['class' => 'form-control input-sm']])]); // set advanced filters $this->setAdvancedFilters([new InputField(['model' => $model, 'attribute' => 'third_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'third.id']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($model->third_id) ? Third::findOne(['id' => $model->third_id])->id : '']]), new InputField(['model' => $model, 'attribute' => 'first_name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, 'attribute' => 'last_name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, 'attribute' => 'email', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, 'attribute' => 'default_language', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'language_i18n.title']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($model->default_language) ? LanguageI18n::findOne(['language_id' => $model->default_language, 'i18n_id' => $language])->title : '']]), new InputField(['model' => $model, 'attribute' => 'user_status', 'type' => 'activeDropDownList', 'data' => $dropDownList('user.status'), 'options' => ['class' => 'form-control input-sm']]), new InputField(['model' => $model, 'attribute' => 'user_active_password_reset', 'type' => 'activeDropDownList', 'data' => $dropDownList('checkbox-drop-down-list'), 'options' => ['class' => 'form-control input-sm']]), 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']])]), 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']])])]); }
/** * @inheritdoc */ public function init() { parent::init(); // set titles $this->setUpdateTitle(Yii::t('kalibao.backend', 'rbac_user_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 = []; $items[] = new InputField(['model' => $models['main'], 'attribute' => 'first_name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('first_name')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'last_name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('last_name')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'email', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('email')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'default_language', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'language_i18n.title']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($models['main']->default_language) ? LanguageI18n::findOne(['language_id' => $models['main']->default_language, 'i18n_id' => $language])->title : '']]); $items[] = new InputField(['model' => $models['user'], 'attribute' => 'password', 'type' => 'activePasswordInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['user']->getAttributeLabel('password')]]); $items[] = new InputField(['model' => $models['user'], 'attribute' => 'password_repeat', 'type' => 'activePasswordInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['user']->getAttributeLabel('password_repeat')]]); $this->setItems($items); }
/** * @return \yii\db\ActiveQuery */ public function getLanguageI18ns() { return $this->hasMany(LanguageI18n::className(), ['language_id' => 'id']); }