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'),

     $this->createUrl('groupmembers/create'),

     array(

     'type'=>'POST',

        'beforeSend'=>'function(){

             $("#joinGroup").addClass("loading");}',

        'complete' => 'function(){

            $("#joinGroup").removeClass("loading");}',

        'success'=>"function(data)

                  {

                    // 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'

                    

                  }",

        'data'=>array('groupID'=>$model->id,'userID'=>$currentUser,'ajax'=>'ajax'),

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

        ),

     array('id'=>'joingroup'));



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

		 $this->performAjaxValidation($model);

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

        // new member.

           $flag=true;

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

    		{

    		  $flag=false;

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

              

              if($model->save()){

                    echo "welcome data is saved";


    			}else{

    			 echo "model not saved";

    			}

              

    		}

            if($flag){

                   $this->renderPartial('_formDialog',array(

    		      	'model'=>$model

    	           	),false, true);

            }


	}



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





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

	'id'=>'mydialog',

	// additional javascript options for the dialog plugin

	'options'=>array(

		'title'=>'Join This Group',

		'autoOpen'=>true,

		'modal'=>true,

        

	),

));

?>

<h1>Join Group</h1>


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


<div class="form">


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

	'id'=>'groupmembers-form',

	'enableAjaxValidation'=>false,

)); ?>


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


	<div class="row">

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

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

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

	</div>


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

	<div class="row">

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

		<div>

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

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

	</div>

	<?php endif; ?>


    <div class="row">

	

		<?php 

        

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

        CHtml::normalizeUrl(array('groupmembers/create','render'=>false)),

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

                       

                        alert(data);

                        

                    }'),

        array('id'=>'saveitem')); 

        

      

        

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

         ?>

	</div>




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


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




<?php 

$this->endWidget('zii.widgets.jui.CJuiDialog');


// 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:

[list=1]

[*]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

[/list]

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