Include HTML code into CHtml::tag()

Im trying to include ‘div’ tags into CHtml::tag … but doesnt display <div> tags

The Code example




<?php

  echo CHtml::tag('button', array('type'=>'submit'), '<div><div>Button</div></div>');

?>



This code should be generate this structure, but i can’t get it




<button type="submit">

  <div>

    <div>Button</div>

  </div>

</button>



CHtml::tag output this




<button type="submit">

  Button

</button>



Are you shure that the observed changes in the right viewer?

…as code of tag() method is no doubt:


	public static function tag($tag,$htmlOptions=array(),$content=false,$closeTag=true)

	{

		$html='<' . $tag . self::renderAttributes($htmlOptions);

		if($content===false)

			return $closeTag ? $html.' />' : $html.'>';

		else

			return $closeTag ? $html.'>'.$content.'</'.$tag.'>' : $html.'>'.$content;

	}

Yii 1.1.1 …

Yup Nagash im sure the view it’s the correct

The version of framework that i use is yii-1.1.0.r1700

And the past version of Yii it’s work…

i’ve download the last stable version yii-1.1.1.r1907 and i got the same problem… any idea ??

strange… I use this code, and it’s works fine.

try modify tag() in: framework/web/helper/CHtml.php and add in first line die(‘test tag()’);

if app will die, then i don’t know, why it’s not work. (can you show your code, maybe some misprint? )

uhh, if i use die(‘something’); my app dies at the first call to CHtml class … well it´s normal

The complete code for button is this




<?php

  echo CHtml::tag('button', array(

    'name'=>'btnSubmit',

    'type'=>'submit'

  ), '<div><div>'.$model->isNewRecord ? "Create" : "Save".'</div></div>');

?>



The difference it’s just $model->isNewRecord ? “Create” : “Save” … mmm, in fact when i delete this line everything runs well

Try this:




<?php

  echo CHtml::tag('button', array(

    'name'=>'btnSubmit',

    'type'=>'submit'

  ), '<div><div>'.($model->isNewRecord ? "Create" : "Save").'</div></div>');

?>

Check the parentesis!

read manuals…

correct use is:




  echo CHtml::tag('button', array(

    'name'=>'btnSubmit',

    'type'=>'submit'

  ), '<div><div>'.($model->isNewRecord ? "Create" : "Save").'</div></div>');



damn…

I didnt know that i had to use parentesis

now, got it… thnx for the help…

It might pay off to take some time and read about operator precedence…

Hi i am new to yii, i want to know if we need to include html helper to use chtml, as in my app when i used the code chtml it made the page die. I also want to know how to check errors, Please help.

Thanks