How Yii Generates Dom

Dear friends,

I’m experiencing a behaviour of Yii that illustrates that I must be missing something.

To be short: this is the code in view/layouts/main.php:

<div class="large-3 columns">



  echo "some test text";



<footer>This is a footer</footer>

Strange enough, but the generated html

<div class="large-3 columns">

   <ul id="yw0">... text from render partial goes here ... </ul>

  <div style="clear:both;"> some test text </div> <---- WHERE THIS DIV TAG COMES FROM?!

  <footer> This is a footer </footer> <---- WHY IS IT NESTED INSIDE THE DIV?


is quite different from what I was expecting:

<div class="large-3 columns">

   text from render partial goes here 

   some test text <--- WITHOUT ANY ADDITIONAL DIV TAG


<footer> This is a footer </footer> <---- NOT NESTED INSIDE DIV TAG

Could anybody shed ligth on what’s wrong here and how to generate desired html?

comment that


If the problem be solved check your _small view file

In any case, I am sure that you have forget to close a tag! :)

Most probably, you’re right. I noticed that with commenting that line, the problem disappears.

But the _small view contains this code:










(please, don’t kill me for this cose, it’s a legacy one). And I don’t see any missing tag.

ha, no I will not ‘kill’ you :)

did you use this extension?

comment this widget and check this code

echo CHtml::dropDownList(‘modelname’, $items[0][‘items’][0], $items[0][‘items’]);

also comment both of them to check if the problem will be fixed

Thanks for not killing me :slight_smile:

Concerning the problem:


[*] if I comment lines corresponding to $this->widget(…), the problem dispapears.

[*] if I insert the code that you suggested

echo CHtml::dropDownList('modelname', $items[0]['items'][0], $items[0]['items']);

(with the widget lines being commented), the problem persists.

[*] even more interesting: if I drop out the arguments of the widget, so that it acquires the form


the problem still persists!


Probably I’m using the widget in a wrong way??

may the $items[0] has problem

check this

echo CHtml::dropDownList('modelname', 1, array(1=>'item1',2=>'item1',1=>'item3'));

or make a similar check with the widget

I’ve just now found the origin of the bug: the widget in its turn referred to extentions/CDropDownMenu.php, which method

protected function renderDropDownMenu(...)

contained unbalanced

echo '<div style="clear:both;">';

So, it is exactly as you had said: the presence of an unclosed tag! Thanks a lot!