HtmlHelper | $html->div() の第2引数を null にすると閉じ </div> が出力されない

24 views
Skip to first unread message

custar

unread,
Sep 15, 2009, 9:39:05 PM9/15/09
to CakePHP-ja
$html->div() はその第2引数に content を指定する。

function div($class = null, $text = null, $attributes = array(),
$escape = false)

しかし、定義通り第2引数を null としてしまうと、
div() から呼ばれる tag() 内部において

if ($text === null)
{
$tag = 'tagstart';
}

と解釈されてしまい、tagstart のフォーマットは '<%s%s>' なので、閉じタグが出力されない。
tagend というのもあるが、自動的に補完してくれる様子はない。

if ($text === null)
{
$tag = 'tagstart';
$tagend = $this->output(sprintf($this->tags['tagend'], $name));
}

と変更して、出力時に繋げてあげればいいが、core を弄っているので、
簡単に済ますには、
第2引数に null 以外を指定すればよい。
Reply all
Reply to author
Forward
0 new messages