MY Controller
<?php
class ChangePasswordController extends Controller{
public function actionChangePassword()
{
$model=new User;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('changepassowrd',array(
'model'=>$model,
));
}
}
?>
My Model user:
<?php
/**
* This is the model class for table "user".
*
* The followings are the available columns in table 'user':
* @property integer $id
* @property string $password
* @property string $type
* @property string $email
* @property integer $is_active
* @property integer $is_deleted
* @property string $created_date
*
* The followings are the available model relations:
* @property Student[] $students
* @property StudentCourseRelation[] $studentCourseRelations
*/
class User extends CActiveRecord
{
public $verifyCode;
/**
* @return string the associated database table name
*/
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('password, type, email, is_active, is_deleted, created_date', 'required'),
array('is_active, is_deleted', 'numerical', 'integerOnly'=>true),
array('password', 'length', 'max'=>150),
array('type', 'length', 'max'=>1),
array('email', 'length', 'max'=>50),
array('email', 'email'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, password, type, email, is_active, is_deleted, created_date', 'safe', 'on'=>'search'),
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
);
}
/**
* @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(
'students' => array(self::HAS_MANY, 'Student', 'user_id'),
'studentCourseRelations' => array(self::HAS_MANY, 'StudentCourseRelation', 'user_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'password' => 'Password',
'type' => 'Type',
'email' => 'Email',
'is_active' => 'Is Active',
'is_deleted' => 'Is Deleted',
'created_date' => 'Created Date',
);
}
/**
* 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('id',$this->id);
$criteria->compare('password',$this->password,true);
$criteria->compare('type',$this->type,true);
$criteria->compare('email',$this->email,true);
$criteria->compare('is_active',$this->is_active);
$criteria->compare('is_deleted',$this->is_deleted);
$criteria->compare('created_date',$this->created_date,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);
}
}
MY View Changepassword
<?php
/* @var $this SiteController */
$this->pageTitle=Yii::app()->name;
?>
<h1>Register Here</h1>
<?php /** @var BootActiveForm $form */
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'verticalForm',
'htmlOptions'=>array('class'=>'well'),
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->labelEx($model,'email'); ?>
<?php echo $form->textField($model,'email',array('size'=>50,'maxlength'=>50)); ?>
<?php echo $form->error($model,'email'); ?>
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password',array('size'=>60,'maxlength'=>150)); ?>
<?php echo $form->error($model,'password'); ?><br/>
<?php if(CCaptcha::checkRequirements()): ?>
<?php echo $form->labelEx($model,'verifyCode'); ?>
<div>
<?php $this->widget('CCaptcha'); ?><br/>
<?php echo $form->textField($model,'verifyCode'); ?>
</div>
<div class="hint">Please enter the letters as they are shown in the image above.
<br/>Letters are not case-sensitive.
</div>
<?php echo $form->error($model,'verifyCode'); ?>
<?php endif; ?>
<?php echo CHtml::submitButton($model->isNewRecord ? 'Register' : 'Save'); ?>
<?php $this->endWidget(); ?>
Error is :
Error 404
Unable to resolve the request "changepassword".
Plz tell me what is going wrong.
I am new in Yii