/** * @param $profile Profile * @param $form ActiveForm * @return string */ public function renderField($profile, $form) { $input = $form->field($profile, $this->varname); if ($widgetEdit = $this->widgetEdit($profile, ['formField' => $input])) { return $widgetEdit; } elseif ($this->range) { return $input->dropDownList(Profile::range($this->range)); } elseif ($this->field_type == "TEXT") { return $input->textarea(['rows' => 6, 'cols' => 50]); } else { return $input->textInput(['size' => 60, 'maxlength' => $this->field_size ? $this->field_size : 255]); } }
} Module::getInstance()->setMenu($menu); ?> <h1><?php echo Module::t('Your profile'); ?> </h1> <?php $attributes = ['username', 'email:email', 'create_at:date', 'lastvisit_at:date']; $profileFields = ProfileField::find()->forOwner()->sort()->all(); if ($profileFields) { foreach ($profileFields as $field) { $val = ''; if ($field->widgetView($model->profile)) { $val = $field->widgetView($model->profile); } else { if ($field->range) { $val = Profile::range($field->range, $model->profile->getAttribute($field->varname)); } else { $val = $model->profile->getAttribute($field->varname); } } $type = 'html'; if ($field->field_type == "DATE" || $field->widget == "UWjuidate") { $type = 'date'; } array_push($attributes, ['label' => Module::t($field->title), 'name' => $field->varname, 'format' => $type, 'value' => $val]); } } echo DetailView::widget(['model' => $model, 'attributes' => $attributes]);
?> <?php echo $form->field($model, 'email'); ?> <?php $profileFields = Profile::getFields(); if ($profileFields) { foreach ($profileFields as $field) { /**@var \marsoltys\yii2user\models\ProfileField $field*/ $input = $form->field($profile, $field->varname); if ($widgetEdit = $field->widgetEdit($profile)) { echo $widgetEdit; } elseif ($field->range) { echo $input->dropDownList(Profile::range($field->range)); } elseif ($field->field_type == "TEXT") { echo $input->textarea(['rows' => 6, 'cols' => 50]); } else { echo $input->textInput(['size' => 60, 'maxlength' => $field->field_size ? $field->field_size : 255]); } } } ?> <?php if (Module::doCaptcha('registration')) { echo $form->field($model, 'captcha')->widget(\yii\captcha\Captcha::classname(), ['captchaAction' => '/site/captcha'])->hint(Module::t("Please enter the letters as they are shown in the image above.") . "<br/>" . Module::t("Letters are not case-sensitive.")); } ?>