/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new ElectiveGroups(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['ElectiveGroups'])) { $model->attributes = $_POST['ElectiveGroups']; if ($model->save()) { $this->redirect(array('/courses/subjects', 'id' => $_REQUEST['id'])); } } $this->render('create', array('model' => $model)); }
public function actionAjax_Create() { if (isset($_POST['ElectiveGroups'])) { $model = new ElectiveGroups(); //set the submitted values $model->attributes = $_POST['ElectiveGroups']; //return the JSON result to provide feedback. if ($model->save(false)) { echo json_encode(array('success' => true, 'id' => $model->primaryKey)); exit; } else { echo json_encode(array('success' => false)); exit; } } }
public function actionAjax_Create() { if (isset($_POST['ElectiveGroups'])) { $model = new ElectiveGroups(); $subject = new Subjects(); //set the submitted values $model->attributes = $_POST['ElectiveGroups']; //return the JSON result to provide feedback. if ($model->save(false)) { $subject->name = $model->name; $subject->code = $model->code; $subject->batch_id = $model->batch_id; $subject->no_exams = 0; $subject->max_weekly_classes = 3; $subject->elective_group_id = $model->id; $subject->is_deleted = 0; $subject->created_at = date('Y-m-d h:i:s'); $subject->save(); echo json_encode(array('success' => true, 'id' => $model->primaryKey)); exit; } else { echo json_encode(array('success' => false)); exit; } } }