每次创建输入字段时,都要使用
$this->Form->input('name');它创建一个div元素。
<div class="input name">
  <input type="text">
</div>是否有办法防止在输入字段周围创建div块。另外,有没有一种方法可以将自定义类添加到创建的div中?喜欢
<div class="input name myStyle">
  <input>
</div>我用的是CakePHP 3.2
发布于 2016-07-19 12:41:20
您需要重写模板。您可以通过创建一个新的配置文件来做到这一点:
config/app_form.php
return [
    'inputContainer' => '{{content}}'
];然后将其加载到视图中:
src/View/AppView.php
class AppView extends View
{
    public function initialize()
    {
        parent::initialize();
        $this->loadHelper('Form', ['templates' => 'app_form']);
    }
}http://book.cakephp.org/3.0/en/views/helpers/form.html#customizing-the-templates-formhelper-uses
发布于 2016-07-19 13:10:15
php echo $this->Form->create($user, ['type' => 'file', 'id'=>"change-profile-form",'role' => 'form','class'=>'orb-form']);
$this->Form->templates(['inputContainer' => '{{content}}']);
echo $this->Form->input('first_name', ['label'=>false, 'div'=>false, 'placeholder' => 'First name']);我希望这能帮到你。
https://stackoverflow.com/questions/38458193
复制相似问题