Post Data To Controller Withou Model

Hi,

Any idea how to post data to controller using ajax without the model.

means i handle the model-data in controller?

suggestion pls?

can you check this wiki

http://www.yiiframework.com/wiki/388/ajax-form-submiting-in-yii/

hi ter,

Let me explain wat i did,

first of all i created my own form without using yii framework.

Why? because that time we havent decided wana use which framework isit yii or smtg else.

After my form created,im start using it deploy into yii framework.

of course this not proper way.

then i did validation using my own jquery script.

now the issue is the data is not saving into database.after i created the model for the form.

the form got multi related tables.

this is my code. form laf.php




  

    

<div class="form">

<!--?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'student-form',

	'enableAjaxValidation'=>TRUE,

)); ?-->	

	

	

<form action="<?php echo Yii::app()->createAbsoluteUrl("student/create"); ?>" method="POST" id="student-form">

  <input type='hidden' name="issubmit" value="1">

<!-- Tabs -->

  		<div id="wizard" class="swMain">

  			<ul>

  				<li><a href="#step-1">

                <label class="stepNumber">1</label>

                <span class="stepDesc">

                   Maklumat Peribadi<br />

                   <small>Butir-Butir Pemohon</small>

                </span>

            </a></li>

  				<li><a href="#step-2">

                <label class="stepNumber">2</label>

                <span class="stepDesc">

                   Keluarga / Penjaga<br />

                   <small>Butir-Butir Pemohon</small>

                </span>

            </a></li>

  				<li><a href="#step-3">

                <label class="stepNumber">3</label>

                <span class="stepDesc">Maklumat Persekolahan<br />

                <small>Butir-Butir Pemohon</small></span></a></li>

  				<li><a href="#step-4">

                <label class="stepNumber">4</label>

                <span class="stepDesc">

                   Pekerjaan / Pendapatan<br />

                <small>Butir-Butir Pemohon</small>

                </span>

            </a></li>

            <li><a href="#step-5">

              <label class="stepNumber">5</label>

                <span class="stepDesc">Document /Pengakuan<br />

                   <small>Butir-Butir Pemohon</small>

              </span>

            </a></li>

  			</ul>

		  <div id="step-1">		

            <h2 class="StepTitle">Langkah 1: Maklumat Peribadi</h2>

			<br/>

      <table cellspacing="3" cellpadding="3" align="center">

                    <tr>

                    	<td align="right"><strong>Maklumat Peribadi</strong></td>

                    	<td align="left">

                      	</td>

                    	<td align="left"><span id="msg_userphoto"></span>&nbsp;</td>

          			</tr>     

           			<tr>

                    	<!--td align="right">&nbsp;</td>

                    	<td align="left"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/applicationForm/default.gif.jpg" class="userphoto"/></td>

                    	<td align="left"><span></span>&nbsp;</td-->

                    	<td align="right">&nbsp;</td>

<td align="left">

<!--iframe src="http://localhost/au/index.php" style="border: medium none; height: 250px;width: 80%;"></iframe-->

 </td>

                    	<td align="left"><span></span>&nbsp;</td

          			</tr>

          			<tr>

                    	<td align="right"><span class='valid'>*</span> Nama Pemohon </td>

                    	<td align="left">

                    	<input type="text" id="nama" name="nama" value="Student1" title="" class="txtBox" size="50px">

                      	</td>

                    	<td align="left"><span class="valid" id="msg_nama"></span>&nbsp;</td>

          			</tr>

          			 <tr>

                    	<td align="right"><span class='valid'>*</span> Emel </td>

                    	<td align="left">

                    	<input type="text" id="emel" name="emel" value="v@yahoo.com"  class="txtBox" size="50" title="">

                        </td>

                    	<td align="left"><span class="valid" id="msg_emel"></span>&nbsp;</td>                        

          			</tr>


          			<tr>

                    	<td align="right"><span class='valid'>*</span>Institusi </td>

                    	<td align="left">

                    	<input type="text" id="institusi" name="institusi" value="test12345" class="txtBox" size="50px" title="">

                      	</td>

                    	<td align="left"><span class="valid" id="msg_institusi"></span>&nbsp;</td>

          			</tr>

          			<tr>

                    	<td align="right"><span class='valid'>*</span>Cawangan </td>

                    	<td align="left">

                    	<input type="text" id="cawangan" name="cawangan" value="tesst1234" class="txtBox" size="50px" title="">

                      	</td>

                    	<td align="left"><span class="valid" id="msg_cawangan"></span>&nbsp;</td>

          			</tr>

          			<tr>

                    	<td align="right"><span class='valid'>*</span>Kursus Pengajian </td>

                    	<td align="left">

                    	<input type="text" id="kursus" name="kursus" value="1231243" class="txtBox" size="50px" title="">

                      	</td>

                    	<td align="left"><span class="valid" id="msg_kursus"></span>&nbsp;</td>

          			</tr>

          			<tr>

                    	<td align="right"><span class='valid'>*</span>Peringkat Kursus(Sijil,Diploma,Ijazah) </td>

                    	<td align="left">

                    	<input type="text" id="peringkat" name="peringkat" value="" class="txtBox" size="50px" title="">

                      	</td>

                    	<td align="left"><span class="valid" id="msg_peringkat"></span>&nbsp;</td>

          			</tr>

          			<tr>

                    	<td align="right"><span class='valid'>*</span>No.K.P. - Baru </td>

                    	<td align="left">

                    	<input type="text" id="nokp" name="nokp" value="850222055367" class="txtBox" size="11px" maxlength="12" title="">

                        </td>

                    	<td align="left"><span class="valid" id="msg_nokp"></span>&nbsp;</td>

          			</tr> 

               	    <tr>

                    	<td align="right">Lama </td>

                    	<td align="left">

                    	<input type="text" id="nokplama" name="nokplama" value="" class="txtBox" size="7px" maxlength="8" title="">

                        </td>

                    	<td align="left"><span class="valid"  id="msg_nokplama"></span>&nbsp;</td>

          			</tr>      

                    <tr>

                    	<td align="right"><span class='valid'>*</span>Bangsa </td>

                    	<td align="left">

                   		 <select name="bangsa" id="bangsa" class="txtBox">

						   <option value="0">-Sila Pilih-</option>

                          <option value="M">Melayu</option>

                          <option value="C">Cina</option>

                          <option value="I">India</option>

                          <option value="L">Lain-Lain</option>

                         </select>	

                         </td>

                    	<td align="left"><span class="valid" id="msg_bangsa"></span>&nbsp;</td>

          			</tr>

                    <tr>

                    	<td align="right"><span class='valid'>*</span>Jantina </td>

                    	<td align="left">

                		<div id='gender' class=''>      

                        <input type="radio" class="txtBox" name="jantina" checked="checked" id="jantina" value="male">Lelaki

                        <input type="radio" class="txtBox" name="jantina" id="jantina" value="female">Perempuan

                        </div>

                        </td>

                        <td align="left"><span class="valid" id="msg_jantina"></span>&nbsp;</td>

          			</tr>   

                    <tr>

                    	<td align="right"><span class='valid'>*</span> Status </td>

                    	<td align="left">

                   		<select name="status" id="status" class="txtBox">

						  <option value="0">-Sila Pilih-</option>

                          <option value="bujang">Bujang</option>

                          <option value="berkahwin">Berkahwin</option>

                          <option value="duda">Duda</option>

                          <option value="janda">Janda</option>

                         </select>

                         </td>

                    	<td align="left"><span class="valid" id="msg_status"></span>&nbsp;</td>

          			</tr>

                    <tr>






StudentController




<?php


class StudentController extends Controller

{

	

	

	

	public function actionIndex()

	{

		$this->render('index');

	}





public function actionLaf()

	{

				

		$this->render('laf/laf');

	}

	

	

 

	 

	

    /**

     * Creates a new model.

     * If creation is successful, the browser will be redirected to the 'view' page.

     */

    public function actionCreate()

    {

        $model=new Student;


        // Uncomment the following line if AJAX validation is needed

        // $this->performAjaxValidation($model);

   

   

   

   

//        $model->nama 

  //      $model->emel

        $model->ApplicantDetail_NewIc = $_POST['institusi'];

        $model->ApplicantDetail_NewIc = $_POST['cawangan'];

        $model->ApplicantDetail_NewIc = $_POST['kursus'];


//        $model->peringkat

//echo 		$model->ApplicantDetail_NewIc = $_POST['nokp'];       

//echo 		$model->ApplicantDetail_Old = $_POST['nokplama'];       

  

 

  //      $model->bangsa

//echo		$model->ApplicantDetail_Gender = $_POST['jantina'];

		

    /*  $model->status

        $model->alamat

        $model->alamat1

        $model->poskod

        $model->notelr

        $model->nohp

        $model->alamatsuratmenyurat

        $model->alamatsuratmenyurat1

        $model->poskodalamatsuratmenyurat

        $model->notelralamatsuratmenyurat

        $model->nohpalamatsuratmenyurat

        $model->negerilahir

        $model->daerahlahir

        

		

*/


        if(isset($_POST['Student']))

        {

         // $model->attributes=$_POST['Student'];

		  

echo 		$model->ApplicantDetail_NewIc = $_POST['nokp'];       

echo 		$model->ApplicantDetail_Old = $_POST['nokplama']; 


 

			if($model->validate()){

			    $model->save(false);

				die(CVarDumper::dump($model->errors,10,true));

			     $this->redirect(array('view','id'=>$model->PkApplicantDetail_Id));  

			  }

			  else{

			     echo CHtml::errorSummary($model);

			}

	    }


        $this->render('laf/laf',array('model'=>$model,

        ));

    }

	 

	 

	 

	// Uncomment the following methods and override them if needed

	/*

	public function filters()

	{

		// return the filter configuration for this controller, e.g.:

		return array(

			'inlineFilterName',

			array(

				'class'=>'path.to.FilterClass',

				'propertyName'=>'propertyValue',

			),

		);

	}


	public function actions()

	{

		// return external action classes, e.g.:

		return array(

			'action1'=>'path.to.ActionClass',

			'action2'=>array(

				'class'=>'path.to.AnotherActionClass',

				'propertyName'=>'propertyValue',

			),

		);

	}

	*/

	

	public function actionUpload()

{

        Yii::import("ext.EAjaxUpload.qqFileUploader");

 

		$folder=Yii::app() -> getBasePath() . "/../images/uploads/";// folder for uploaded files

        $allowedExtensions = array("jpg","png","pdf");//array("jpg","jpeg","gif","exe","mov" and etc...

        $sizeLimit = 5  * 1024 * 1024;// maximum file size in bytes

        $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);

        $result = $uploader->handleUpload($folder);

        $return = htmlspecialchars(json_encode($result), ENT_NOQUOTES);

 

        $fileSize=filesize($folder.$result['filename']);//GETTING FILE SIZE

        $fileName=$result['filename'];//GETTING FILE NAME

        echo $return;// it's arrayYii::import('application.extensions.image.Image');


}





      

 


}



model -> Student.php




<?php


/**

 * This is the model class for table "applicantdetail".

 *

 * The followings are the available columns in table 'applicantdetail':

 * @property integer $PkApplicantDetail_Id

 * @property integer $ApplicantDetail_NewIc

 * @property integer $ApplicantDetail_Old

 * @property string $ApplicantDetail_Gender

 * @property string $ApplicantDetail_MarriageStatus

 * @property string $ApplicantDetail_JobBeforeCourse

 * @property string $ApplicantDetail_Employer

 * @property integer $ApplicatDetail_EmployerNoTel

 * @property string $ApplicantDetail_LastIncome

 * @property string $ApplicantDetail_Document

 *

 * The followings are the available model relations:

 * @property Application $application

 * @property Commitment $commitment

 * @property Contact $contact

 * @property Examresult $examresult

 * @property Extracurricular $extracurricular

 * @property Extraeducationresult $extraeducationresult

 * @property Learningcenter $learningcenter

 * @property Race $race

 * @property Relative $relative

 */

class Student extends CActiveRecord

{

		

	 

	/**

	 * Returns the static model of the specified AR class.

	 * @param string $className active record class name.

	 * @return Student the static model class

	 */

	public static function model($className=__CLASS__)

	{

		return parent::model($className);

	}


	/**

	 * @return string the associated database table name

	 */

	public function tableName()

	{

		return 'applicantdetail';

	}


	/**

	 * @return array validation rules for model attributes.

	 */

	public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('ApplicantDetail_NewIc, ApplicantDetail_Old, ApplicatDetail_EmployerNoTel', 'numerical', 'integerOnly'=>true),

			array('ApplicantDetail_Gender', 'length', 'max'=>10),

			array('ApplicantDetail_MarriageStatus', 'length', 'max'=>20),

			array('ApplicantDetail_JobBeforeCourse', 'length', 'max'=>30),

			array('ApplicantDetail_Employer', 'length', 'max'=>255),

			array('ApplicantDetail_LastIncome', 'length', 'max'=>6),

			

			array('ApplicantDetail_NewIc, ApplicantDetail_Old, ApplicatDetail_EmployerNoTel', 'numerical','safe'),

			

			// The following rule is used by search().

			// Please remove those attributes that should not be searched.

			array('PkApplicantDetail_Id, ApplicantDetail_NewIc, ApplicantDetail_Old, ApplicantDetail_Gender, ApplicantDetail_MarriageStatus, ApplicantDetail_JobBeforeCourse, ApplicantDetail_Employer, ApplicatDetail_EmployerNoTel, ApplicantDetail_LastIncome, ', 'safe', 'on'=>'search'),

		);

	}


	/**

	 * @return array relational rules.

	 */

	public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

			'application' => array(self::HAS_ONE, 'Application', 'applicantdetail_PkApplicantDetail_Id'),

			'commitment' => array(self::HAS_ONE, 'Commitment', 'applicantdetail_PkApplicantDetail_Id'),

			'contact' => array(self::HAS_ONE, 'Contact', 'applicantdetail_PkApplicantDetail_Id'),

			'examresult' => array(self::HAS_ONE, 'Examresult', 'applicantdetail_PkApplicantDetail_Id'),

			'extracurricular' => array(self::HAS_ONE, 'Extracurricular', 'applicantdetail_PkApplicantDetail_Id'),

			'extraeducationresult' => array(self::HAS_ONE, 'Extraeducationresult', 'applicantdetail_PkApplicantDetail_Id'),

			'learningcenter' => array(self::HAS_ONE, 'Learningcenter', 'applicantdetail_PkApplicantDetail_Id'),

			'race' => array(self::HAS_ONE, 'Race', 'applicantdetail_PkApplicantDetail_Id'),

			'relative' => array(self::HAS_ONE, 'Relative', 'applicantdetail_PkApplicantDetail_Id'),

		);

	}


	/**

	 * @return array customized attribute labels (name=>label)

	 */

	public function attributeLabels()

	{

		return array(

			'PkApplicantDetail_Id' => 'Pk Applicant Detail',

			'ApplicantDetail_NewIc' => 'Applicant Detail New Ic',

			'ApplicantDetail_Old' => 'Applicant Detail Old',

			'ApplicantDetail_Gender' => 'Applicant Detail Gender',

			'ApplicantDetail_MarriageStatus' => 'Applicant Detail Marriage Status',

			'ApplicantDetail_JobBeforeCourse' => 'Applicant Detail Job Before Course',

			'ApplicantDetail_Employer' => 'Applicant Detail Employer',

			'ApplicatDetail_EmployerNoTel' => 'Applicat Detail Employer No Tel',

			'ApplicantDetail_LastIncome' => 'Applicant Detail Last Income',

			'ApplicantDetail_Document' => 'Applicant Detail Document',

		);

	}


	/**

	 * Retrieves a list of models based on the current search/filter conditions.

	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.

	 */

	public function search()

	{

		// Warning: Please modify the following code to remove attributes that

		// should not be searched.


		$criteria=new CDbCriteria;


		$criteria->compare('PkApplicantDetail_Id',$this->PkApplicantDetail_Id);

		$criteria->compare('ApplicantDetail_NewIc',$this->ApplicantDetail_NewIc);

		$criteria->compare('ApplicantDetail_Old',$this->ApplicantDetail_Old);

		$criteria->compare('ApplicantDetail_Gender',$this->ApplicantDetail_Gender,true);

		$criteria->compare('ApplicantDetail_MarriageStatus',$this->ApplicantDetail_MarriageStatus,true);

		$criteria->compare('ApplicantDetail_JobBeforeCourse',$this->ApplicantDetail_JobBeforeCourse,true);

		$criteria->compare('ApplicantDetail_Employer',$this->ApplicantDetail_Employer,true);

		$criteria->compare('ApplicatDetail_EmployerNoTel',$this->ApplicatDetail_EmployerNoTel);

		$criteria->compare('ApplicantDetail_LastIncome',$this->ApplicantDetail_LastIncome,true);

		$criteria->compare('ApplicantDetail_Document',$this->ApplicantDetail_Document,true);


		return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

		));

	}

}




Looking for the cause, trying to insert data for one table only for now - > applicantdetail

Pls help me to solve this issue.

Thanks