cakephp表单助手$ this->数据为空

时间:2011-12-03 16:36:12

标签: cakephp cakephp-2.0 formhelper

我遇到的问题是返回$this->data的表单助手一直是空的。在我的表格之前没有问题,我无法弄清楚这里有什么不同。 对于此表单,没有包含数据的模型,它只是用于搜索的用户输入。

这是我的观点:

<?php
echo $this->Form->create();
echo $this->Form->input('Postleitzahl');
$options=array('10'=>10,'20'=>20);
echo $this->Form->input('Entfernung',array('type'=> 'select' , 'options'=>array(($options))));
echo $this->Form->end('Suchen');
?>

3 个答案:

答案 0 :(得分:2)

<?php

    echo $this->Form->create(null, array('type' => 'post')); # not sure if that's needed
    echo $this->Form->input('Search.Postleitzahl');
    $options=array('10'=>10,'20'=>20);
    echo $this->Form->input('Search.Entfernung',array('options'=> $options)); # seems shorter and should work
    echo $this->Form->end('Suchen');

?>

上述内容应该会产生一个包含类似内容的$this->data数组:

['Search']
    ['Postleitzahl']: 102929
    ['Enfernung']: 'foobar'

答案 1 :(得分:1)

请不要对数组进行双重数组:

'options'=>$options

答案 2 :(得分:0)

不一定与Cake相关,但是当我拥有它时问题的答案:如果你在POST中包含文件上传,请仔细检查你上传的文件是否不大于指定的限制在php.ini文件中。