简体   繁体   English

CakePHP表单帮助程序问题,带有编辑日期

[英]CakePHP form helper problem with date for editing

I'm quite newbie in CakePHP, I've tried to create a form with form helper on a date field 我是CakePHP的新手,我尝试在日期字段上使用表单助手创建表单

echo $this->Form->input('Item.date');

yes, works fine (I'm using CakePHP v1.3.3) for input/add new record but when I try using it on edit page it does nothing. 是的,可以很好地用于输入/添加新记录(我正在使用CakePHP v1.3.3),但是当我尝试在编辑页面上使用它时,它什么也没做。 here's the code 这是代码

echo $this->Form->input('Item.date', array("value"=>$rs['Item']['date']));

it still display listbox without retrieving the value from desired table. 它仍然显示列表框,而没有从所需表中检索值。 Any help appreciated, sorry for my english.. 任何帮助表示赞赏,对不起我的英语。

you shouldnt use inline params for default values. 您不应该使用内联参数作为默认值。 pass them down from the controller: 将它们从控制器传下来:

http://www.dereuromark.de/2010/06/23/working-with-forms/ http://www.dereuromark.de/2010/06/23/working-with-forms/

see "default-values" 请参阅“默认值”

我使用选定的选项找到了答案:

echo $this->Form->input('Item.date', array('selected'=>$rs['Item']['date']));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM