How To Call Ajax

It display on setting page

hi

it’s open a below a setting page or repalce the setting page? in your change password form

how would be open in your porject?

open in below setting page

which one i mean controller or something?

in controller your password action and setting page when you display password from

ok

u can change the function


public function actionPassword($id) {

        

        $user = app()->user->getUser();

        if (isset($user->id) && $user->id === $id || app()->user->isAdmin()) {

            $model = $this->loadModel($id);

            $model->setScenario('changePassword');

            if (isset($_POST['User'])) {

                $model->attributes = $_POST['User'];

                if ($model->validate()) {

                    $model->password = crypt($_POST['User']['pass1'], Randomness::blowfishSalt());

                    if ($model->save()) {

                        app()->user->setFlash('success', 'Saved new password!');

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

                    }

                }

            }


            //$this->render('/user/password', array('model' => $model));

//            $this->renderPartial('/user/password', array('model' => $model),false,true);

        } else {

            // access denied for this user

            throw new CHttpException(403, 'Access Denied.');

        }

	 $this->renderPartial('/user/password', array('model' => $model),false,true);

    }

and setting.php please correct the syntax u can pass a id using wrong syntax


<?php echo CHtml::ajaxlink('Change Password', array('/user/password', 'id' =>Yii::app()->user->id), array('update' => '.inner_tab_contant'), array("live" => false)); ?>

Now also showing new page and submit button action is not working.

Ok sorry…

so u can revert the function and it’s display the setting page or not?

and also remove the inner_tab_content div in your password page


<?php

/* @var $this UserController */

/* @var $model User */


if($model->id===app()->user->id){

    $breadcrumbs = array(

        'Profile' => array('/user/update', 'id' => app()->user->id),

        'Change Password'

    );

} else {

    $breadcrumbs = array(

        'Users' => array('/user/index'),

        $model->email => array('/user/update', 'id' => $model->id),

        'Change Password'

    );

}


//$this->layout = app()->user->isAdmin()?'column2':'';

//$this->pageTitle = app()->name . ' - Change Password';

//$this->breadcrumbs = $breadcrumbs;


$this->menu=array(

	array('label'=>'List User', 'url'=>array('index')),

	array('label'=>'Create User', 'url'=>array('create')),

);

?>


<!--<h1>Change <?php echo $model->email; ?> Password</h1>-->


<p>Fields with <span class="required">*</span> are required.</p>


    <?php

    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(

        

        'id' => 'changePass-form',

        'type' => 'horizontal',

        'enableAjaxValidation' => false,

        'clientOptions' => array(

                'validateOnSubmit' => true,


            ),

        'htmlOptions' => array(

                'onsubmit' => "return false;",

            ),




    ));

    ?>


    <?php //echo $form->errorSummary($model); ?>


    <fieldset>


        <?php if(!app()->user->isAdmin()): ?>


            <?php echo $form->passwordFieldRow($model, 'old_password', array('size' => 60, 'maxlength' => 63)); ?>


        <?php endif; ?>


        <?php echo $form->passwordFieldRow($model, 'pass1', array('size' => 60, 'maxlength' => 63)); ?>


        <?php echo $form->passwordFieldRow($model, 'pass2', array('size' => 60, 'maxlength' => 63)); ?>


    </fieldset>


    <div class="form-actions">

        <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'label'=>'Change Password')); ?>

        <?php echo CHtml::link('Link Text',array('user/password?id=942'),array('class'=>'aa','onclick'=>'test()')); ?>

     

    </div>

    

    <?php $this->endWidget(); ?>



It’s displaying on setting page but submit button action is not working

ok it’s diaplay password error(validation rule) or not?

No, it diplaying submit button and its not working and one more link is displaying "Link Text" when click this link it saying Error403: Access denied.

ooh…sorry

just remove the link text after submit button on your password page and thenafter click the submit button

please let me know it’s display the error or not?

and also try the chnage code


<?php

    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(

        

        'id' => 'changePass-form',

	'action'=>'password'

        'type' => 'horizontal',

        'enableAjaxValidation' => false,

        'clientOptions' => array(

                'validateOnSubmit' => true,


            ),

        'htmlOptions' => array(

                'onsubmit' => "return false;",

            ),




    ));

    ?>

Sir, its not displaying any error, only submit button action action is not working.

can u pass the right syntax, please check


$this->renderPartial('/user/password', array('model' => $model),false,true);

yah, i written correctly.

ok can u send the again code if u don’t mind?

Hi

u can try the my action


public function ChangePassword($id){

		$model=Users::model()->findByPk((int)$id);

		

		if(isset($_POST['Users']['password']) && !empty($_POST['Users']['password']))

		{

			

			$modelForm->password_repeat = $_POST['Users']['password_repeat'];


			$model->password=md5($modelForm->password_repeat);

			$model->save(false);




			if (!$model->hasErrors()) {

				$this->redirect(array('admin'));

			}else {

				Yii::app()->user->setFlash('error', "Password change failure!");

				$this->redirect(array('admin'));

			}

		}

		$this->render('/users/password',array('model'=>$model));


	}