how to call controler action from the outside

Hey all

I’m using a the CjuiDialog for a pop up window… I wan to use it in order for users to become members.

I created my Member model and Crudd.

now, in my home page I put the following code




<?php                

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

        'id'=>'loginDialog',

                        'options'=>array(

                            'title'=>'get notification',

                            'autoOpen'=>true,  // set to auto open for testing only

                            'draggable'=>true,

                            'resizable'=>false,

                            'closeOnEscape' => true,                                                       

                            'show'=>'fade',

                            'hide'=>'fade',

                            'position'=>'center',

                            'modal'=>true,

                        )                       

        

        )

        

);


?>





// this is the actual Form created with my CRUD for my Member model.

// In order to see my model I had to set it explicitly  with this line $model = Member::model();

<div class="form">


 <?php

 $model = Member::model();

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

	'id'=>'member-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,'email'); ?>

		<?php echo $form->textField($model,'email',array('size'=>20,'maxlength'=>100)); ?>

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

	</div>


	<div class="row">

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

		<?php echo $form->textField($model,'lname',array('size'=>20,'maxlength'=>50)); ?>

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

	</div>


	<div class="row">

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

		<?php echo $form->textField($model,'fname',array('size'=>20,'maxlength'=>50)); ?>

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

	</div>


	<div class="row buttons">

		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>

	</div>


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


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


<?php

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



in order to "see" the Member model I had to do this (not sure if this is the best way) before calling the form


 $model = Member::model();

that all works, I see my form inside my pop up… but when I hit the save button, nothing gets saved to my DB. I assume it’s because the action “save” is not recognized at the lever I’m in… how do I call the Member controler action in order to save from my home page??

thanks for any leads

Pabs

in searching around, I’ve heard comments about using a widget to achieve what I want…

is this a good approach? if so, how would you go about creating a widget from an existing model?

Pabs

The reason you are having to use $model = Member::model(); is because it appears that you are not creating a new model anywhere or passing this model from the controller to the page. It would be helpful if we could see the controller end of your code.

You may also find this link helpful:

Popup with Ajaxlink

OR

Creating a new Record in a Popup (I suspect this will help you more).