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

Als*_*any 1 html css cakephp form-helpers

在cakephp

echo $this->Form->input('email', array('type' => 'email'));
Run Code Online (Sandbox Code Playgroud)

将呈现

<div class="input email">
<label for="UserEmail">Email</label>
<input type="email" name="data[User][email]" value="" id="UserEmail" />
Run Code Online (Sandbox Code Playgroud)

如何做到这一点

    <input type="email" name="data[User][email]" value="" id="UserEmail" class="input_class" style="some:style;" />
Run Code Online (Sandbox Code Playgroud)

nul*_*ity 13

只需在options数组中添加"class"和/或"style"参数即可.

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

有关所有选项的列表,请参阅FormHelper文档.

  • `some:style`是原帖中使用的. (3认同)