Saturday, March 2, 2019

In yii how to render view in widget




In yii i am creating project.



Now i want to create widget for displaying new password insertion window.
For resetting password,user needs to enter security question's answer correctly.
After this he will be provided with two radio buttons.
One is having label as "Change password here" and other as "Send password reset link to mail".



So when user will clicks first radio button,this widget will get rendered which will have two textfields for entering new password and repeat password, and also submit button. So how to implement this widget.



I had created simple widget saying hello as:




class Sample extends CWidget {
public function init() {
Yii::app()->getClientScript()->registerScript('SampleWidget',"alert('Hello');");
}
}


So how to add textfields and submit button to this widget. Or how to render any view form in this widget. Please help me.


Answer




Rendering a widget is the same as rendering any other view. Just set layout property to a different value so you don't get the header again. public $layout='//layouts/noheader'; You can set that property in your method like $this->layout = '//layouts/noheader'. This will also let you do custom things for example I have a layout that is for popups. You should also create it as a partial so it can be used in other places.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...