/** * @inheritdoc */ public function init() { parent::init(); // set titles $this->setCreateTitle(Yii::t('kalibao', 'create_title')); $this->setUpdateTitle(Yii::t('kalibao', '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()]; $uploadConfig['company'] = $this->uploadConfig[(new \ReflectionClass($models['company']))->getName()]; // set items $items = []; $items[] = new InputField(['model' => $models['company'], 'attribute' => 'company_type', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'company_type_i18n.title']), 'data-allow-clear' => 1, 'data-add-action' => Url::to('/third/company-type/create'), 'data-update-action' => Url::to('/third/company-type/update'), 'data-update-argument' => 'id', 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($models['company']->company_type) ? CompanyTypeI18n::findOne(['company_type_id' => $models['company']->company_type, 'i18n_id' => $language])->title : '']]); $items[] = new InputField(['model' => $models['company'], 'attribute' => 'name', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['company']->getAttributeLabel('name')]]); $items[] = new InputField(['model' => $models['company'], 'attribute' => 'tva_number', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['company']->getAttributeLabel('tva_number')]]); $items[] = new InputField(['model' => $models['company'], 'attribute' => 'naf', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['company']->getAttributeLabel('naf')]]); $items[] = new InputField(['model' => $models['company'], 'attribute' => 'siren', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['company']->getAttributeLabel('siren')]]); $items[] = new InputField(['model' => $models['main'], 'attribute' => 'note', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('note')]]); if (!$models['main']->isNewRecord) { $items[] = new SimpleValueField(['model' => $models['company'], 'attribute' => 'created_at', 'value' => Yii::$app->formatter->asDatetime($models['main']->created_at, I18N::getDateFormat())]); $items[] = new SimpleValueField(['model' => $models['company'], 'attribute' => 'updated_at', 'value' => Yii::$app->formatter->asDatetime($models['main']->updated_at, I18N::getDateFormat())]); } $this->setItems($items); }
/** * @return \yii\db\ActiveQuery */ public function getCompanyTypeI18ns() { return $this->hasMany(CompanyTypeI18n::className(), ['company_type_id' => 'id']); }