Form In Header

Hello!

I am trying to create a login form in the header of the page. It seems that passing the form instance as a parameter to $this->render will not work, since the variable will not be visible from the header. The only way I see is to create a public variable in the controller and access from the view via $this->var

Is there a better way?

Thanks!

Alternatively, you could package the login form up as a widget.

As Keith said , the best solution is using widget also you can use render_partil just u need to change

your action in login form and add full controller name like this :


<?php 

..........

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

        'id'=>'events-serach_block-form',

/// change code to be like this 

'action'=>array('searchcontrollerid/searchactionid'),

        'enableAjaxValidation'=>false,

)); 

...............

?>

I hope will help .

[b]

[/b]

Thank you both for your reply

In fact, i am trying to create a widget to render the login form.

Here is the thing. I’ve managed to encapsulate a login form view and its actions into a widget, but I have problems while trying to show validation errors to the user, since the page needs to be rendered again. I need to pass the validated form to the widget in order to show the messages in the widget view, so I was going to do it as a parameter of the widget, but I found the problem reported in this thread (visibility of the form instance in the header)

As a reference, please take a look at this unanswered post I created recently describing this problem: http://www.yiiframework.com/forum/index.php/topic/43355-widgets-and-forms/

How can I handle correctly the form instance in the widget?