本文整理汇总了PHP中UserForm::hasErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP UserForm::hasErrors方法的具体用法?PHP UserForm::hasErrors怎么用?PHP UserForm::hasErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserForm
的用法示例。
在下文中一共展示了UserForm::hasErrors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEdit
public function actionEdit()
{
$request = Yii::$app->request;
$user = User::findOne($request->get('id'));
$model = new UserForm();
$model->attributes = $user->attributes;
if ($model->load($request->post()) && $model->validate()) {
//Overall assignment the attributes of $user must be safe attributes
$user->attributes = $model->attributes;
// var_dump($model->attributes);
// var_dump($user->attributes);exit();
if ($user->save()) {
$this->redirect(array('index'));
} else {
}
} else {
if ($model->hasErrors()) {
// foreach($model->getErrors() as $error){
// var_dump($error,false);
// }
}
}
return $this->render('edit', ['model' => $model]);
}
示例2:
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Installation</title>
<link rel="stylesheet" type="text/css" href="<?php
echo Bootstrap::getBooster()->getAssetsUrl();
?>
/bootstrap/css/bootstrap.min.css" />
</head>
<body>
<div class="span6 offset3">
<h1 class="offset1">Installation</h1>
<h2 class="offset1"><small>Enter admin credentials</small></h2>
<?php
if ($model->hasErrors()) {
?>
<?php
echo TbHtml::errorSummary($model);
?>
<?php
}
?>
<form method="post" class="form-horizontal">
<?php
echo TbHtml::activeTextFieldControlGroup($model, 'username');
?>
<?php
echo TbHtml::activePasswordFieldControlGroup($model, 'password');