Cakephp - 复选框名称
目前,我已经成功创建了复选框。 我设置的数组如下:
$emailName = $this->User->find('list', array(
'fields' => array('User.username', 'User.email')
));
输出如下:
array
'admin' => string '[email protected]' (length=11)
'test' => string '[email protected]' (length=14)
'Floo' => string '[email protected]' (length=16)
我试图使复选框显示用户名而不是 view.ctp 中的用户电子邮件。
我尝试在 view.ctp 中使用以下代码
<?php echo $this->Form->input('Address_list.['.$emailName['username'].']', array(
'type' => 'select',
'multiple' => 'checkbox',
'options' => $emailName['email']
)); ?>
但是,这似乎不起作用。有什么想法吗?
Currently, i have succeeded in creating the checkbox.
The array which i have setup is as below:
$emailName = $this->User->find('list', array(
'fields' => array('User.username', 'User.email')
));
The output is as follows:
array
'admin' => string '[email protected]' (length=11)
'test' => string '[email protected]' (length=14)
'Floo' => string '[email protected]' (length=16)
I'm trying to make the checkbox shows the username instead of the user email in view.ctp.
I have tried using the following code in view.ctp
<?php echo $this->Form->input('Address_list.['.$emailName['username'].']', array(
'type' => 'select',
'multiple' => 'checkbox',
'options' => $emailName['email']
)); ?>
However, it seems that this doesn't work. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有正确格式化复选框列表的表单字段。尝试将其更改为:
但是,这将根据用户选择的电子邮件返回用户名的值。它创建这样的表单:
You are not formatting your form field for the checkbox list correctly. Try changing it to this:
However, this will return the value of Username based on the selection of Email the user chooses. It creates the form like this: