本文整理汇总了PHP中Comments::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::getErrors方法的具体用法?PHP Comments::getErrors怎么用?PHP Comments::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments::getErrors方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComment
/**
* Creates a new comment
* TODO: Figure out how to fix the email issues
* @param int $id The Comment id
* @return array
*/
private function createComment()
{
$model = new Comments();
$model->attributes = $_POST;
$model->approved = Cii::getConfig('autoApproveComments', 0);
if ($model->save()) {
return $model->getApiAttributes();
}
return $this->returnError(400, NULL, $model->getErrors());
}
示例2: beforeAction
protected function beforeAction($action)
{
if (isset($_REQUEST['Comments'])) {
$comment = $_REQUEST['Comments'];
//Yii::app()->notify->add("Добавлен комментарий");
if (isset($comment)) {
if (isset($comment['id']) and isset($comment['model'])) {
}
$entry = new Comments();
$entry->entryid = $comment['id'];
$entry->comment = $comment['comment'];
$entry->model = "Solutions";
$entry->student = Yii::app()->my->id;
if ($entry->save()) {
Yii::app()->notify->add("Добавлен комментарий ");
} else {
Yii::app()->notify->addErrors($entry->getErrors());
}
}
}
return true;
}
示例3: actionReply
public function actionReply($id)
{
$reply = Comments::model()->findByPk($id);
$comment = new Comments();
if (isset($_POST['Comments'])) {
$comment->attributes = $_POST['Comments'];
$comment->model = $reply->model;
$comment->object_id = $reply->object_id;
$comment->user_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : 0;
if ($comment->validate()) {
$comment->appendTo($reply);
Yii::app()->session['caf'] = CMS::time();
$data = array('code' => 'success', 'flash_message' => Yii::t('CommentsModule.default', 'COMM_SUCCESS_REPLY'));
} else {
$data = array('code' => 'fail', 'response' => $comment->getErrors());
}
echo CJSON::encode($data);
} else {
$reply->unsetAttributes(array('text'));
Yii::app()->clientScript->scriptMap = array('jquery.js' => false);
$this->render('_reply_form', array('model' => $reply), false, true);
}
}
示例4: addComment
public function addComment($params = array())
{
extract($params);
if (isset($dynamic_id) && isset($user_id) && $user_id && $dynamic_id) {
$comment = array('dynamic_id' => $dynamic_id, 'user_id' => $user_id);
if (isset($content) && $content) {
$comment['content'] = $content;
}
if (isset($image) && $image) {
if (!is_null(json_decode($image))) {
$images = json_decode($image);
$comment['images'] = implode(',', $images);
} else {
$comment['images'] = $image;
}
}
if (isset($content) && $content || isset($image) && $image) {
$model = new Comments();
$model->attributes = $comment;
if ($model->validate() && $model->save()) {
$ret = $this->notice('OK', 0, '成功', []);
} else {
$ret = $this->notice('ERR', 307, '操作数据错误', $model->getErrors());
}
} else {
$ret = $this->notice('ERR', 303, '没有评论内容', []);
}
} else {
$ret = $this->notice('ERR', 301, '缺少关键参数', []);
}
return $ret;
}
示例5: actionAfterPost
public function actionAfterPost($st_id, $c_id, $j_id, $pr_id)
{
$model = new Comments();
// uncomment the following code to enable ajax-based validation
/*
if(isset($_POST['ajax']) && $_POST['ajax']==='job-profile-_form-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
*/
if (isset($_POST['Comments'])) {
$model->txt = $_POST['Comments']['txt'];
$model->st_id = $st_id;
$model->c_id = $c_id;
$model->j_id = $j_id;
$model->pr_id = Yii::App()->user->id;
if ($model->validate()) {
// form inputs are valid, do something here
$model->save();
Yii::app()->user->setFlash('success', 'Comment Posted Successfully ');
$this->redirect(array('index'));
return;
} else {
var_dump($model->getErrors());
echo 'validation problem';
}
}
}