public function actionPurchaseOrder() { $model = new Suppliers(); $count_sql = "SELECT COUNT(*) FROM purchase_order"; $total_records = Yii::app()->db->createCommand($count_sql)->queryScalar(); if ($total_records == 0) { $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'juiDialog', 'options' => array('title' => 'Add Suppliers', 'autoOpen' => true, 'modal' => 'true', 'show' => 'blind', 'hide' => 'explode'), 'cssFile' => Yii::app()->request->baseUrl . '/css/jquery-ui.css')); echo 'Please add some suppliers to raise purchase order'; $this->endWidget(); } if (isset($_POST['Suppliers'])) { $model->attributes = $_POST['Suppliers']; if ($model->validate()) { // form inputs are valid, do something here return; } } $this->render('purchaseOrder', array('model' => $model)); }