redering anothers view and validating that view through its own modal is not working

so far after reading this (topic) i have came across this

in the groups view

echo CHtml::ajaxLink(Yii::t('Groups','Join Group'),






        'complete' => 'function(){




                    // handle return data

                   // alert( 'welcome' );

                    alert( data ); // it does alert the data

                    $('#joinGroup').replaceWith(data); // if i comment this no data is show even if i m using 'update'=>'#joinGroup'




        'update'=>'#joinGroup' // joinGroup is a div in the view



in the groupmembers controller

 public function actionCreate()


	       $groupID = $_POST['groupID'];

           $userID = $_POST['userID'];


           $model=new Groupmembers;

           $model->group_id = $groupID;

           $model->user_id = $userID;


       	// Uncomment the following line if AJAX validation is needed


         // Flag to know if we will render the form or try to add 

        // new member.








                    echo "welcome data is saved";


    			 echo "model not saved";







    	           	),false, true);



and this the view (_formDialog) which is called in this view function

<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array(


	// additional javascript options for the dialog plugin


		'title'=>'Join This Group',







<h1>Join Group</h1>

<!-- echo 'dialog content here';-->

<div class="form">

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



)); ?>

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

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

	<div class="row">

		<?php echo $form->labelEx($model,'group_id'); ?>

		<?php echo $form->textField($model,'group_id'); ?>

		<?php echo $form->error($model,'group_id'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'user_id'); ?>

		<?php echo $form->textField($model,'user_id'); ?>

		<?php echo $form->error($model,'user_id'); ?>


      <?php if(CCaptcha::checkRequirements()): ?>

	<div class="row">

		<?php echo $form->labelEx($model,'verifyCode'); ?>


		<?php $this->widget('CCaptcha'); ?>

		<?php echo $form->textField($model,'verifyCode'); ?>


		<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; ?>

    <div class="row">




        echo CHtml::ajaxSubmitButton(Yii::t('Groups','Join Group'),


        array('success'=>'function(data) {









        echo CHtml::normalizeUrl(array('groupmembers/create'));



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

</div><!-- form -->



// the link that may open the dialog

echo CHtml::link('Join Group Now', '#', array(

	'onclick'=>'$("#mydialog").dialog("open"); return false;',



now the main issues are:


[*]when i click on the join button it properly loads the dialog rendered from the controller but when i click on the submit button nothing happens

[*]as i have used the captcha too i no captcha or wrong captcha is entered or even no value is entered in any field the form is not validated and no errors are shown

[*]even if i input the right values in the form it is still not submitted, nothing happens


can anyone plz tell me where i might be creating wrong logic or how to do it properly ?

This code is completely different from the one of my tutorial.

The code of the view should not be changed at all, you can use the gii generated code.

All the trick is in the code that generates the dialog.

Try to follow carefully the tutorial and it will work. I tested it with captcha too and works properly.

but how will i transfer the data from current page to the page which i m rendering with out using the

'data'=>array('my data...'),

in your tutorial there is no such thing can u plz elaborate more

The data will be sent by post. If you need to pass additional data, you can just add some hidden fields or put in the data of the ajax request (is a bit more difficoult, because you have to merge with the serliazed form data )

i have now followed exactly what is in your article and the values are only saved when they are correct but still if the values are wrong or empty it does not show any errors like on normal forms, my point is how will user know if he is entering correct value or not.

one thing more the captch refresh button remains out of the dialog on the page behind it can it be fixed??

can u share your code with captcha used in it i can’t yet figure out the real issue