Failed To Open Stream: No Such File Or Directory

Hi,

I am newly to yii framework.

I try to create a register form but it give this statement==> include(MyCActiveForm.php): failed to open stream: No such file or directory

view file


<div class =" twelve column">

    <div>Register Form</div>

    <div>

        <?php

        $form = $this->beginWidget('MyCActiveForm', array(

            'id' => 'register-form',

            'enableAjaxValidation' => true,

            'enableClientValidation' => true,

            'clientOptions' => array(

                'validateOnSubmit' => true,

            ),

            'action' => Yii::app()->createUrl('//site/processregister') // must specify a another link for form to be submitted to.

        ));

        ?>

        <br />

        <div>

            <div>

                <div>

                        <?php echo $form->labelEx($modelRegister, $modelRegister::FIRSTNAME); ?>

                        <?php echo $form->textField($modelRegister, $modelRegister::FIRSTNAME,array('style'=>'padding:0px; margin:0px;')); ?>


                </div>


            </div>

        </div>

    </div>

</div>

site controller


public function actionRegister() {


        $modelRegister = new User();


        $this->render('register', array('modelRegister'=> $modelRegister));

    }


    //process registration when user submit registration form

    public function actionProcessregister() {

        $modelRegister = new User();

      

         $this->performAjaxValidation($modelRegister);

       

        $command = Yii::app()->db->createCommand();

        $command->insert('user', array(

            'FirstName' => $_POST['User'][$modelRegister:: FIRSTNAME],


            'AddDate' => date("Y-m-d H:i:s"),

        ));


        //$pkId = Yii::app()->db->lastInsertID;

   }

User model


<?php


/**

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

 *

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

 * @property integer $UserID

 * @property string $Username

 * @property string $FirstName

 * @property string $LastName

 * @property string $Password

 * @property string $HashKey

 * @property string $Email

 * @property string $Phone

 * @property string $AddDate

 * @property string $LasrUpdate

 */

class User extends CActiveRecord {


    /**

     * @return string the associated database table name

     */

   

    CONST FIRSTNAME = "FirstName";

   


    

    public function tableName() {

        return 'user';

    }


    /**

     * @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(self::FIRSTNAME, 'required', 'message' => "Please fill in your first name"),

            array('Username, FirstName, LastName, Password, HashKey, Email, Phone, AddDate, LasrUpdate', 'required'),

            array('Username, FirstName, LastName, Password, HashKey, Email, Phone', 'length', 'max' => 256),

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

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

            array('UserID, Username, FirstName, LastName, Password, HashKey, Email, Phone, AddDate, LasrUpdate', '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(

        );

    }


    /**

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

     */

    public function attributeLabels() {

        return array(

            'UserID' => 'User',

            'Username' => 'Username',

            self::FIRSTNAME => 'FirstName',

            'LastName' => 'Last Name',

            'Password' => 'Password',

            'HashKey' => 'Hash Key',

            'Email' => 'Email',

            'Phone' => 'Phone',

            'AddDate' => 'Add Date',

            'LasrUpdate' => 'Lasr Update',

        );

    }


    /**

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

     *

     * Typical usecase:

     * - Initialize the model fields with values from filter form.

     * - Execute this method to get CActiveDataProvider instance which will filter

     * models according to data in model fields.

     * - Pass data provider to CGridView, CListView or any similar widget.

     *

     * @return CActiveDataProvider the data provider that can return the models

     * based on the search/filter conditions.

     */

    public function search() {

        // @todo Please modify the following code to remove attributes that should not be searched.


        $criteria = new CDbCriteria;


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

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

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

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

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

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

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

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

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

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


        return new CActiveDataProvider($this, array(

            'criteria' => $criteria,

        ));

    }


    /**

     * Returns the static model of the specified AR class.

     * Please note that you should have this exact method in all your CActiveRecord descendants!

     * @param string $className active record class name.

     * @return User the static model class

     */

    public static function model($className = __CLASS__) {

        return parent::model($className);

    }


}



i not sure if i miss out anything. I just test to insert firstname into database but end out PHP warning.Hope got any guide.So,i able to learn from mistake to improve my knowledge to yii.thank you.

Unless you’ve created your own class called MyCActiveForm, you should be using CActiveForm.

where did you copy your code from?


<?php

...

        $form = $this->beginWidget('MyCActiveForm', array( // change MyCActiveForm to 

...

        $form = $this->beginWidget('CActiveForm', array( 

thank…it work…i check back my previous internship’s exercise.