1

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');
?>
2
  • also do a debug($this->data) to be certain in your action Commented Dec 3, 2011 at 17:30
  • Maybe you could use it directly from $this->params? Commented Dec 3, 2011 at 17:37

3 Answers 3

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

?>

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

['Search']
    ['Postleitzahl']: 102929
    ['Enfernung']: 'foobar'
Sign up to request clarification or add additional context in comments.

Comments

1

Just don't double array your array:

'options'=>$options

2 Comments

changed that ...but still the same..problem , maybe it is because it doesnt represent a model in the database and i have to declare the input variables somehow ?
there should always be some model. either use a "fake" model name like "Form" in order to use the posted data in the controller - or even better use a real model with $useTable=false (this way you can have validation on your forms without using any real tables).
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.