如何修改cakephp输入中的(style,class ..)等参数?

时间:2013-05-06 19:13:16

标签: html css cakephp form-helpers

在cakephp中

echo $this->Form->input('email', array('type' => 'email'));

将呈现

<div class="input email">
<label for="UserEmail">Email</label>
<input type="email" name="data[User][email]" value="" id="UserEmail" />

如何做到这一点

    <input type="email" name="data[User][email]" value="" id="UserEmail" class="input_class" style="some:style;" />

2 个答案:

答案 0 :(得分:13)

只需在选项数组中添加“class”和/或“style”参数即可。

echo $this->Form->input('email', array('type' => 'email', 'class' => 'input_class', 'style' => 'some:style' ));

请参阅the FormHelper documentation以获取所有选项的列表。

答案 1 :(得分:2)

如果您只需要没有标签的输入,您也可以尝试这种方式

echo $this->Form->input('email', array('type' => 'email','div'=>false, 'class' => 'input_class', 'style' => 'some:style' ));