我想知道是否可以为表单视图提供别名(名称与mysql表中的名称不同)。
例如,我的用户表格如下:
id | username | password | email | group_id | first_name | last_name | created | modified 1 | admin | somepass | mail | 3 | Name | last | date | date
添加ctp文件看起来像:
Form->create('User'); ?>
Form->input('username');
echo $this->Form->input('password');
echo $this->Form->input('email');
echo $this->Form->input('group_id');
echo $this->Form->input('first_name');
echo $this->Form->input('last_name');
?>
Form->end(__('Submit')); ?>
我想知道的是,可以为每个字段提供一个将在网页上显示的别名。
例如:
echo $this->Form->input('username', alias 'Your username');
echo $this->Form->input('username', alias 'Your username');
答案 0 :(得分:2)
echo $this->Form->input('username', array('label' => 'Your username'));
http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#creating-form-elements