如何在CakePHP 3中转换下面的代码?
问题描述:
<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文件,我不知道如何将它转换成像如何在CakePHP 3中转换下面的代码?
<? echo $this->Html->input('title',['class'=>'']);
答
你必须使用的,而不是CakePHP的HTML辅助形式帮手。表单助手可帮助您创建表单字段以及帮助验证表单。但Html帮助程序可帮助您创建Html,如图像显示一样。在这里,我们去
$this->Form->input('title', [
'label' => [
'text' => 'Title',
'class' => 'col-lg-2'
],
'style' => [
'width: 45%;'
]
]);
我想提醒你去这个链接,对文档从深层次看:)