Display form in a Widget???

Hi Everybody,

I’ve made a theme from my layout by Photoshop

When I want to display an actionCreate by Widget I’ve got this problem!

Code Render:

<?php $this->widget('application.components.MainContentBox',

                    array('title'=>'Create Event',

                        'content'=>$this->renderPartial('_form', array('model'=>$model)),



And I got this result:



My Widget:


class MainContentBox extends CWidget


    public $title;

    public $content;

    public function run()





Views file:

<div class="main-box border-line">

    <div class="main-title">

        <span><?php echo $this->title ?></span>


    <div class="main-content">

        <br />

        <?php $this->content ?>



Even I comment this line <?php $this->content ?> I still got the same result!

My CSS Code:



    border: 1px solid #e5e5e5;




    padding: 0 10px;

    font-weight: bold;

    background: #f7f7f7;

    line-height: 25px;

    border-bottom: 1px solid #e5e5e5;


.main-content {}

Do you think $this->renderPartial is so hard to display in a DIV? Help me solve this problem or Give me a new method! Thanks!


please take a look at CController::renderPartial. You have to assign third parameter, for returning output instead of direct outputing.

$this->renderPartial('_form', array('model'=>$model, true)

best regards


[color="#006400"]/* moved to Yii 1.1 help forum */[/color]

@bn77: tks bro, i’ll check it now

@jacmoe: tks for moving this topic ^^

Done now ^^