Hello,
I have a form in a view which is created using the FormHelper in the
following way:
echo $this->Form->create(False, array('action' => 'something', 'type'
=> 'get'));
I then have an input for the form defined in the following way:
echo $this->Form->input('department', array('id' => 'department',
'options' => $departments, 'empty' => '(select)'));
When the form type is set to Get in this way, the HTML rendered for
the form input does not contain a name attribute (the name attribute
is empty):
<select name="" id="department"> ... </select>
But when I change the form type to Post like this:
echo $this->Form->create(False, array('action' => 'something', 'type'
=> 'post'));
and render the same input, the resulting HTML is:
<select id="department" name="data[department]"> ... </select>
Why does the name disappear for Get type forms? I noticed that this
hidden input is not rendered with Get, but it is with Post:
<div style="display: none;"><input type="hidden" value="POST"
name="_method"></div>
This is causing problems when I try to serialize the form data for an
ajax request using the JsHelper - even though the ajax request uses
the POST method, the form data is incomplete because it does not have
any names.
Thanks in advance for your help!
Michael
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en