Question

I have a problem with the Form Helper that returned $this->data keeps being empty. In my Forms before there was no problems and I cant figure out what's different here. For this Form there's not a model containing the data, its just user input for doing a search.

This is my View:

<?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');
?>
Was it helpful?

Solution

<?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');

?>

The above should result into a $this->data array containing something similar to this:

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

OTHER TIPS

Just don't double array your array:

'options'=>$options

Not necessarily related to Cake, but the answer to the problem when I had it: if you're including a file upload in your POST, double-check that the file you're uploading isn't larger than the limit specified in your php.ini file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top