我正在创建窗体并希望使用多个字段集和图例,这可能使用窗体帮助器吗?CakePHP使用窗体帮助器的多个窗体集
我的形式迄今为止 -
echo $this->Form->create('PatientCase');
echo $this->Form->inputs(array(
'legend' => 'Patient Details',
...
));
echo $this->Form->end('Save Patient Case');
我正在创建窗体并希望使用多个字段集和图例,这可能使用窗体帮助器吗?CakePHP使用窗体帮助器的多个窗体集
我的形式迄今为止 -
echo $this->Form->create('PatientCase');
echo $this->Form->inputs(array(
'legend' => 'Patient Details',
...
));
echo $this->Form->end('Save Patient Case');
见API:http://api.cakephp.org/class/form-helper#method-FormHelperinput
主要PARAMS,如:before
,after
,between
或者只是format
如果使用表::输入() CakePHP将自动换行字段中的字段:
echo $this->Form->inputs(array(
'legend'=>'Login',
'User.username',
'User.password'
));
会产生:
<fieldset>
<legend>Login</legend>
<div class='input text'>...</div>
<div class='input password'>...</div>
</fieldset>
如果设置“字段集”在你输入数组=>假,蛋糕将抑制外地字段集标记。
您也可以使用(如也@kical建议)之前和之后插入字段集标记 - 这使你的代码少一点intuative:
echo $this->Form->input('User.username', array(
'before'=>'<fieldset><legend>Login</legend>'
));
echo $this->Form->input('User.password', array(
'after'=>'</fieldset>'
));
您也可以手动插入字段集标记(方便,如果你想字段集内的自定义字段集标记或创建字段集:
<fieldset>
<legend>Login</legend>
<?php
echo $this->Form->input('User.username');
echo $this->Form->input('User.password');
?>
</fieldset>
这应该是公认的答案,使用前/间/只后导致混乱的代码和手工编写HTML代码中使用形式 - > inputs()和图例键将充分利用FormHelpe [R – thaJeztah