$form->输入除姓名之外的复选框外键。蛋糕PHP
如何为除名称或名称以外的输入添加标签,例如
<label for="category_id">Name - Initial</label>
<input id="category" />
我尝试过此操作。
echo $this->Form->input('category_id', array('multiple'=>'checkbox','label' => 'Category.initials'));
这就是我想要实现的目标。
<label for="category_id">Name - Initial</label>
<input id="category" />
来自谷歌的答案!
您可以在模型中创建虚拟字段[1]。
public $virtualFields = array(
'full_name' => 'CONCAT(User.last_name, ", ", User.first_name)'
);
然后,我相信(还没有尝试过)你可以指定 full_name 作为模型的显示字段:
public $displayField = 'full_name';
How can I add label for input other than name or more than name, eg
<label for="category_id">Name - Initial</label>
<input id="category" />
I tried this.
echo $this->Form->input('category_id', array('multiple'=>'checkbox','label' => 'Category.initials'));
This is what I want to achieve.
<label for="category_id">Name - Initial</label>
<input id="category" />
ANSWER FROM GOOGLE!
You can create a virtual field[1] in the model.
public $virtualFields = array(
'full_name' => 'CONCAT(User.last_name, ", ", User.first_name)'
);
Then, I believe (haven't tried this) that you could specify full_name
as the model's display field:
public $displayField = 'full_name';
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解,您可以通过传递一个字符串来将标签设置为您想要的任何内容:
或者您可以从一些预先存在的变量中构建该字符串:
或者我误解了您想要做什么?
As far as I understand it you can set the label to anything you want by passing it a string:
Or you could build that string out of some pre-existing variables:
Or have I misunderstood what you're trying to do?