/** * @inheritdoc */ public function run() { parent::init(); PassfieldAsset::register($this->view); Yii::$app->get('i18n')->translations['passfield*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; if (ArrayHelper::getValue($this->pluginOptions, 'titleShow') === null) { $this->pluginOptions['titleShow'] = Yii::t('passfield', 'Show password'); } if (ArrayHelper::getValue($this->pluginOptions, 'titleHide') === null) { $this->pluginOptions['titleHide'] = Yii::t('passfield', 'Hide password'); } $pluginOptions = Json::encode($this->pluginOptions); $this->view->registerJs(sprintf('$("#%s").passfield(%s)', $this->options['id'], $pluginOptions)); if ($this->hasModel()) { if ($this->form == null) { throw new InvalidConfigException(__CLASS__ . '.form property must be specified'); } return $this->form->field($this->model, $this->attribute, ['template' => $this->template])->passwordInput($this->options)->hint($this->hint); } else { return Html::passwordInput($this->name, $this->value, $this->options); } }
?> <div style="margin-top: 50px;"> <?php echo !empty($passwordInfo) ? Html::tag('div', $passwordInfo, ['class' => 'alert alert-success']) : ''; ?> <h4><?php echo Yii::t('app', 'Change Your Password'); ?> </h4> <?php echo !empty($passwordError) ? Html::tag('div', $passwordError, ['class' => 'alert alert-danger']) : ''; ?> <div class="row"> <div class="col-xs-6"> <?php echo Html::passwordInput('password', '', ['class' => 'form-control', 'placeholder' => Yii::t('app', 'Enter new password')]); ?> </div> <div class="col-xs-6"> <?php echo Html::submitButton(Yii::t('app', 'Update Password'), ['class' => 'btn btn-primary']); ?> </div> </div> </div> <?php ActiveForm::end(); ?> </div> </div>