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:

2403

EVENT.jpg

My Widget:




<?php

class MainContentBox extends CWidget

{

    public $title;

    public $content;


    public function run()

    {

        $this->render('MainContentBox');

    }    

}

Views file:


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

    <div class="main-title">

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

    </div>

    <div class="main-content">

        <br />

        <?php $this->content ?>

    </div>

</div>

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

My CSS Code:




.border-line

{

    border: 1px solid #e5e5e5;

}

.main-title

{

    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!

Hi,

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

robert

[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 ^^