0
我创建了一个注册表单,其中包含返回数组的年份输入(下例)。在cakephp中创建年份表格
$this->Form->year('graduation', 1960, date('Y'));
我收到的错误是如下:
Notice (8): Array to string conversion [CORE/cake/libs/model/datasources/dbo_source.php, line 749]
Code | Context
implode - [internal], line ??
DboSource::create() - CORE/cake/libs/model/datasources/dbo_source.php, line 749
Model::save() - CORE/cake/libs/model/model.php, line 1342
UsersController::register() - APP/controllers/users_controller.php, line 38
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83
Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list' [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
我希望有人指点我朝着正确的方向(例如将刚发现的)
提前感谢!
所以我做了基于罗斯的评论不再抛出和错误的一些变化:
echo $this->Form->input('graduation', array('label' => 'Year of Graduation:',
'type' => 'date',
'dateFormat' => 'Y',
'empty' => true,
'minYear' => 1960, // start year
'maxYear' => date('Y') // current
)
);
现在的问题是在选择甚至一年的时候,在数据库中的值被存储为空
你的帮助是非常感谢。我之前有过类似的下拉菜单,但我只想要一年的选择。有没有另外一种方法呢? – Plastika 2012-03-09 03:04:21
上面的HTML输出是什么?你可能需要指定模型,考虑它。该字段的名称必须是'name ='data [Model] [graduation] [year]“'才能正常工作。尝试使用' - > input('Model.graduation')',而'Model'是合适的。 – Ross 2012-03-09 09:28:15