如何在CakePHP 3中转换下面的代码?

时间:2017-09-16 11:23:55

标签: cakephp cakephp-3.0

<div class="form-group">
      <label for="inputEmail" class="col-lg-2 control-label">Title</label>
      <div class="col-lg-10">
        <input type="text" style="width: 45%;" class="form-control" id="titleId" name="title" placeholder="Title">
      </div>
</div>

我的add.ctp文件中有这种类型的代码,我不知道如何将其转换为类似

<? echo $this->Html->input('title',['class'=>'']);

1 个答案:

答案 0 :(得分:1)

您必须使用Form帮助程序而不是CakePHP Html帮助程序。表单助手可帮助您创建表单字段以及帮助验证表单。但是Html帮助器可以帮助您创建Html,就像Html一样用于图像显示。我们走了

$this->Form->input('title', [
    'label' => [
        'text' => 'Title', 
        'class' => 'col-lg-2'
    ],
    'style' => [
        'width: 45%;'
    ]
]);

我想建议您转到此链接,深入了解文档:)

Here is the Form helper of CakePHP 3

Here is the Html helper of CakePHP 3