表单助手不会自动填写 cakephp 中的“belongsTo”选择框
这让我今天早上/昨晚深夜感到有点沮丧,我确信我一定在这里错过了一些非常简单的东西......
在我看来,我有:
echo $this->Form->input('form_generator_field_type_id');
并且在我的控制器中我有:
$form_generator_field_types=$this->FormField->FormFieldType->find('list');
$this->set('form_generator_field_types',$form_generator_field_types);
这会导致设置 $我认为 form_generator_field_types 是:
Array(
[1] => text
[2] => checkbox
[3] => textarea)
表单助手不是简单地用字段名称的复数版本中的值数组填充字段吗? (即:page_id 会被$pages 填充)?
仅供参考(不确定是否可能是问题的原因,我在 FormField 中定义的 ownTo 关系是:
var $belongsTo = array(
'FormFieldType' => array(
'className' => 'form_generator.FormFieldType',
'foreignKey' => 'form_generator_field_type_id'
)
);
任何方向/建议将不胜感激!
谢谢
This is causing me a bit of frustration this morning/late last night, and I'm sure I must be missing something painfully simple here....
In my view I have:
echo $this->Form->input('form_generator_field_type_id');
and in my controller I have:
$form_generator_field_types=$this->FormField->FormFieldType->find('list');
$this->set('form_generator_field_types',$form_generator_field_types);
Which results in setting $form_generator_field_types in my view to be:
Array(
[1] => text
[2] => checkbox
[3] => textarea)
Doesn't the form helper simply fill in the field with an array of values from a pluralized version of the field name? (ie: page_id would get filled with $pages)?
Just for reference (not sure if it could be the cause of the issue, my belongsTo relationship that is defined in FormField is:
var $belongsTo = array(
'FormFieldType' => array(
'className' => 'form_generator.FormFieldType',
'foreignKey' => 'form_generator_field_type_id'
)
);
Any direction/suggestions would be greatly appreciated!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
弄清楚了我的问题。助手确实会寻找复数变量。但是,我在文档中没有注意到它正在寻找驼峰版本......所以在我的示例中......
应该是
Figured out my problem. The helper does look for a pluralized variable. However, what I failed to notice in the documentation is that it is looking for a camelCased version... so in my example..
should have been