Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Commits on May 01, 2012
Vincent Gabriel added proper display of validation error in forms a34a9c6
Vincent Gabriel update query as it used to be 4ce3f6e
@gmotruk gmotruk Merge pull request #2 from VinceG/master
Updated post model and controller to display errors properly
6c3db6b
View
6 protected/controllers/PostController.php
@@ -39,7 +39,7 @@ public function actionCreate()
if (!$model->save()) {
$errors = array();
foreach ($model->getErrors() as $e) $errors = array_merge($errors, $e);
- throw new CException(implode("\n", $errors));
+ $this->sendResponse(500, implode("<br />", $errors));
}
$this->sendResponse(200);
@@ -60,7 +60,7 @@ public function actionUpdate($id)
if (!$model->save()) {
$errors = array();
foreach ($model->getErrors() as $e) $errors = array_merge($errors, $e);
- throw new CException(implode("\n", $errors));
+ $this->sendResponse(500, implode("<br />", $errors));
}
$this->sendResponse(200);
@@ -76,7 +76,7 @@ public function actionDelete($id)
if (!$model->delete()) {
$errors = array();
foreach ($model->getErrors() as $e) $errors = array_merge($errors, $e);
- throw new CException(implode("\n", $errors));
+ $this->sendResponse(500, implode("<br />", $errors));
}
$this->sendResponse(200);
View
6 protected/controllers/UserController.php
@@ -35,7 +35,7 @@ public function actionCreate()
if (!$model->save()) {
$errors = array();
foreach ($model->getErrors() as $e) $errors = array_merge($errors, $e);
- throw new CException(implode("\n", $errors));
+ $this->sendResponse(500, implode("<br />", $errors));
}
$this->sendResponse(200);
@@ -61,7 +61,7 @@ public function actionUpdate($id)
if (!$model->save()) {
$errors = array();
foreach ($model->getErrors() as $e) $errors = array_merge($errors, $e);
- throw new CException(implode("\n", $errors));
+ $this->sendResponse(500, implode("<br />", $errors));
}
$this->sendResponse(200);
@@ -79,7 +79,7 @@ public function actionDelete($id)
if (!$model->delete()) {
$errors = array();
foreach ($model->getErrors() as $e) $errors = array_merge($errors, $e);
- throw new CException(implode("\n", $errors));
+ $this->sendResponse(500, implode("<br />", $errors));
}
$this->sendResponse(200);
View
12 protected/migrations/m120328_085408_base_db.php
@@ -13,7 +13,7 @@ public function up()
'pw_reset_token' => 'string',
'email' => 'string',
'role' => 'string',
- 'is_deleted' => 'boolean',
+ 'is_deleted' => 'int',
'create_date' => 'datetime',
), 'ENGINE=InnoDB');
@@ -29,7 +29,7 @@ public function up()
'title' => 'string',
'content' => 'string',
'user_id' => 'int',
- 'is_deleted' => 'boolean',
+ 'is_deleted' => 'int',
'create_date' => 'datetime',
), 'ENGINE=InnoDB');
@@ -38,7 +38,7 @@ public function up()
'post_id' => 'int',
'content' => 'string',
'user_id' => 'int',
- 'is_deleted' => 'boolean',
+ 'is_deleted' => 'int',
'create_date' => 'datetime',
), 'ENGINE=InnoDB');
@@ -53,7 +53,7 @@ public function up()
'pw_reset_token' => '',
'email' => 'super@yiibackbone.loc',
'role' => 'admin',
- 'is_deleted' => false,
+ 'is_deleted' => 0,
'create_date' => new CDbExpression('NOW()'),
));
$userId = Yii::app()->db->getLastInsertId();
@@ -62,7 +62,7 @@ public function up()
'title' => 'Lorem Ipsum',
'content' => 'Sed posuere consectetur est at lobortis. Donec id elit non mi porta gravida at eget metus. Donec ullamcorper nulla non metus auctor fringilla. Nullam id dolor id nibh ultricies vehicula ut id elit. Maecenas faucibus mollis interdum.',
'user_id' => $userId,
- 'is_deleted' => false,
+ 'is_deleted' => 0,
'create_date' => new CDbExpression('NOW()'),
));
$postId = Yii::app()->db->getLastInsertId();
@@ -71,7 +71,7 @@ public function up()
'content' => 'Sed posuere consectetur est at lobortis. Donec id elit non mi porta gravida at eget metus. Donec ullamcorper nulla non metus auctor fringilla. Nullam id dolor id nibh ultricies vehicula ut id elit. Maecenas faucibus mollis interdum.',
'post_id' => $postId,
'user_id' => $userId,
- 'is_deleted' => false,
+ 'is_deleted' => 0,
'create_date' => new CDbExpression('NOW()'),
));
}
View
2  protected/models/Post.php
@@ -17,6 +17,8 @@ public function tableName()
public function rules()
{
return array(
+ array('title, content', 'required'),
+ array('title', 'length', 'min' => 3, 'max' => 100),
array('create_date', 'default', 'value' => new CDbExpression('NOW()'), 'setOnEmpty' => false, 'on' => 'insert')
);
}

No commit comments for this range

Something went wrong with that request. Please try again.