本文整理汇总了PHP中Publisher::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Publisher::validate方法的具体用法?PHP Publisher::validate怎么用?PHP Publisher::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publisher
的用法示例。
在下文中一共展示了Publisher::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEdit
/**
* Edit a publisher.
*/
public function actionEdit($id = 0)
{
if ($id > 0) {
$model = Publisher::model()->findByPk($id);
} else {
$model = new Publisher();
}
if (isset($_POST['Publisher'])) {
$model->attributes = $_POST['Publisher'];
if ($model->validate() && $model->save()) {
Yii::app()->user->setFlash('successmsg', 'The changes have been saved.');
$this->redirect('/publisher/index');
} else {
Yii::app()->user->setFlash('errormsg', 'Error saving the publisher page.');
$this->render('edit', array('model' => $model, 'id' => $id));
}
} else {
$this->render('edit', array('model' => $model, 'id' => $id));
}
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Publisher();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Publisher'])) {
$model->attributes = $_POST['Publisher'];
if ($model->validate()) {
if ($model->save()) {
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
echo CJSON::encode(array('status' => 'success', 'div' => "<div class=alert alert-info fade in>Successfully added ! </div>"));
Yii::app()->end();
}
}
}
if (Yii::app()->request->isAjaxRequest) {
$cs = Yii::app()->clientScript;
$cs->scriptMap = array('jquery.js' => false, 'bootstrap.js' => false, 'jquery.min.js' => false, 'bootstrap.notify.js' => false, 'bootstrap.bootbox.min.js' => false);
echo CJSON::encode(array('status' => 'render', 'div' => $this->renderPartial('_form', array('model' => $model), true, false)));
Yii::app()->end();
} else {
$this->render('create', array('model' => $model));
}
}