使用Cake php form helper在form元素内添加html元素 [英] Add html element inside of form element using cake php form helper

查看:103
本文介绍了使用Cake php form helper在form元素内添加html元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个看起来像这样的简单html输出

I am trying to create a simple html output that looks like this

<button class="searchbutton" id="search_button" type="submit">-->
      <i class="icon-search"></i> Search</button>

使用Cake php的表单助手,我无法弄清楚为什么'after'属性没有添加内部<i> </i> html元素.

with Cake php's form helper, i cant figure out why the 'after' attribute doesn't add the inner <i> </i> html element.

这是我尝试过的.

  echo $this->Form->button('Search', array('type' => 'submit','id' => 'search_button','class' => 'searchbutton',
        'after' => "<i class='icon-search'></i>"));

推荐答案

您只需在按钮$title中添加额外的<i></i>标记,还包括'escape' => false以确保标记不会被转义,即使不会像v3.1.1那样默认情况下进行转义,这可能会在将来改变,谁知道呢.

You just include the extra <i></i> tag in the button $title, also include 'escape' => false to ensure the mark up is not escaped, even though is not escaped by default as on v3.1.1, this may change in future, who knows..

示例:

echo $this->Form->button("<i class='icon-search'></i> Search", array('type' => 'submit','id' => 'search_button', 'class' => 'searchbutton', 'escape' => false));

这篇关于使用Cake php form helper在form元素内添加html元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆