本文整理匯總了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');