本文整理汇总了PHP中Batches::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Batches::validate方法的具体用法?PHP Batches::validate怎么用?PHP Batches::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Batches
的用法示例。
在下文中一共展示了Batches::validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Courses();
$model_1 = new Batches();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Courses'])) {
$model_1->attributes = $_POST['Batches'];
$model->attributes = $_POST['Courses'];
$model->validate();
if ($model_1->validate()) {
if ($model->save()) {
$list = $_POST['Batches'];
if (!$list['start_date']) {
$s_d = "";
} else {
$s_d = date('Y-m-d', strtotime($list['start_date']));
}
if (!$list['end_date']) {
$e_d = "";
} else {
$e_d = date('Y-m-d', strtotime($list['end_date']));
}
$model_1->course_id = Yii::app()->db->getLastInsertId();
$model_1->start_date = $s_d;
$model_1->end_date = $e_d;
$model_1->save();
$this->redirect(array('/courses'));
}
}
}
$this->render('create', array('model' => $model, 'model_1' => $model_1));
}