添加一个类来输入cakeDefaults CakePHP的cakephp

时间:2015-04-21 08:47:22

标签: php cakephp form-helpers cakephp-2.5

关注http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html。我可以使用inputDefaults为每个表单字段提供课程,但现在:

必需:我想将某些特定输入中的类(say myClass)附加到inputDefaults继承的那些。

'inputDefaults' => array(
     'label' => false,
     'div' => 'form-group',
     'class' => 'col-sm-6 form-control'
 )

每个输入字段

<input type="email" id="LoginEmail" maxlength="100" required="required" placeholder="Email" class="col-sm-6 form-control" name="data[Login][email]" />

如果我尝试

echo $this->Form->input("email", array("placeholder" => "Email", "required" => "required", "class" => "myClass"));

 <input type="email" id="LoginEmail" maxlength="100" required="required" placeholder="Email" class="myClass" name="data[Login][email]" />

我想跟随

 <input type="email" id="LoginEmail" maxlength="100" required="required" placeholder="Email" class="col-sm-6 form-control myClass" name="data[Login][email]" />

提前致谢!

1 个答案:

答案 0 :(得分:1)

当您尝试使用带有cakephp的twitter bootstrap时,您可能会发现https://github.com/Codaxis/cakephp-bootstrap3-helpers#installation已编码的表单助手

Bs3Helpers.Bs3Form一个别名添加到std Form,如安装部分所示,并在bootstrap.php中配置帮助程序。

另一个提示是烘焙脚本模板:https://github.com/ptica/BootstrapCake