Render Portlet issue

Hello there 2 everyone…

i want to create a portlet that shows only one input for user’s email

i got 2 views:

  • boletinPortlet: display the form with the textField

  • boletinRegistro: shows a message like "you will receive emails from us"

heres the override renderContent method




protected function renderContent()

	{

               $boletin=new Boletin();

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

		{

			$boletin->attributes=$_POST['Boletin'];

			   if($boletin->save ()){

                               $this->render('boletinRegistro',array('boletin'=>$boletin));  

                            }

                }else{

                    $this->render('boletinPortlet',array('boletin'=>$boletin));

                }

        }



The problem is i cannot render the boletinRegistro view… any suggestion?? :blink:

[twitter]rmandovnz[/twitter]

make sure you have boletinPortlet.php view file in the same directory as your portlet class

Thankyou, for your comments, and yes, the boletinPortlet is in place. the folder structure is:

widgets/boletinPortlet.php

widgets/views/boletinRegistro.php

widgets/views/boletinPortlet.php

I notice if i remove the ‘enableAjaxValidation’=>true, line on the form it works but refreshig the page, i think theres something on the widget render when the calls are with ajax.

$form = $this->beginWidget(‘CActiveForm’, array(

    'id' => 'boletin-form',


    'enableAjaxValidation'=>true,


    'enableClientValidation'=>true,


    'clientOptions' => array(


        'validateOnSubmit' => true,


     ),


  ));

So I guess your views has the form code above. It’s risky to have AjaxValidation in the form in a widget view. The reason is your widget is placed in a view which is called by an action. Therefore, you cannot ensure that the widget is the first thing in your view and if so, ajax validation is likely failed.

  1. Form submit

  2. Ajax validation makes an Ajax post

  3. same controller / action handles that post

  4. action doesn’t handle your form because it’s in your widget and therefore it will render the view

  5. only at this moment your widget run

At step 5, if you don’t have the code similar to Yii standard to handle Ajax Validation then the post is step 2 work exactly the same as a real submission. It does go into the if (isset…) and render the view you want. BUT because client is expecting some JSON returned during ajax validation process, this process fails.

Check your database, very likely there are some data saved because this line is executed: [size=2]$boletin[/size][color=#666600][size=2]->[/size][/color][size=2]save [/size][color=#666600]size=2[/size][/color]

Hello there, sorry but im kind of bussyyyy making the other modules of my project.

Thanks for the reply, and yes Hudson, i think you’re right, but for the moment i leave it without the ajax submition.

i promise to make right when i can…

thanks again.

really, even if i leave the project like this i need to know how to fix it ;)