Thomas is right you can post the user id and use that in your action.
Anyway, that issue seems weird, have you set any custom routes? Try
updating the core.
On Tue, Oct 28, 2008 at 11:32 PM, R. Davila <rdavila.gg@gmail.com> wrote:
>
> Hi Thomas,
>
> The POST method is generated by $form->create()
>
> The GET method will put the variables in the URL (visible to the user), so that's not an option.
>
> $form->create() works for the add() and edit() scaffolded functions without problems.
>
> The problem is not the generated HTML, but when submitting the generated form.
> The changePassword function is not receiving the parameter.
>
>
>
> 703designs wrote:
>> You're using a POST method for your form, so you can retrieve the data
>> from $this->data on the controller side. Why would you want POST data
>> in a URL? That's what GET requests are for.
>>
>> Thomas
>>
>> On Oct 28, 6:43 pm, "R. Davila" <rdavila...@gmail.com> wrote:
>>> Hi,
>>>
>>> Sorry, but it didn't work.
>>>
>>> This is what i did (following your example):
>>> <?php echo $form->create('User', array('url' => array('action' => 'changePassword', $form->value('User.id')))); ?>
>>>
>>> And this was the generated html:
>>> <form id="UserEditForm" method="post" action="/users/changePassword/3/3"><fieldset style="display:none;"><input type="hidden" name="_method" value="PUT" />
>>>
>>> Actually I had already tried something similar (hardcoding the parameter) and had seen that generated <form> tag (functionName/id/id).
>>>
>>> The Form Helper is actually creating the <form> tag correctly. The problem is when submitting the generated form.
>>>
>>> If I simply code echo $form->create('User', array('action' => 'changePassword')); the Form Helper correctly generates the <form> tag (adding the parameter at the end).
>>>
>>> The problem is when submitting the generated form.
>>>
>>> Dardo Sordi Bogado wrote:
>>>> Try
>>>> <?php echo $form->create('User', array('url' => array('action' =>
>>>> 'changePassword', 3))); ?>
>>>> I'm sure you'll be able to make it works for others ids than 3 ;)
>>>> HTH,
>>>> - Dardo Sordi.
>>>> On Tue, Oct 28, 2008 at 12:30 AM, R. Davila <rdavila...@gmail.com> wrote:
>>>>> Hi,
>>>>> I have a controller function, and the corresponding view, setup like this:
>>>>> function changePassword($id = null)
>>>>> change_password.ctp
>>>>> <?php echo $form->create('User', array('action' => 'changePassword')); ?>
>>>>> <?php echo $form->hidden('password'); ?>
>>>>> .
>>>>> . Here I add the fields for old password, new password and retype new password
>>>>> .
>>>>> <?php echo $form->end('Submit'); ?>
>>>>> The following is the generated html (the parameter to the changePassword function is the user id, in this case 3):
>>>>> <form id="UserChangePasswordForm" method="post" action="/users/changePassword/3">
>>>>> <fieldset style="display:none;"><input type="hidden" name="_method" value="POST" /></fieldset>
>>>>> <input type="hidden" name="data[User][password]" value="encrypted password value" id="UserPassword" />
>>>>> So far so good.
>>>>> The problem is that when I fill the form fields and click the Submit button,
>>>>> the data is being posted to "/users/changePassword" instead of "/users/changePassword/3"
>>>>> I'm writing $this->params to the FirePHP console at the top of the changePassword function and this is what I get:
>>>>> When I access the page initially:
>>>>> Array
>>>>> (
>>>>> [pass] => Array
>>>>> (
>>>>> [0] => 3
>>>>> )
>>>>> [named] => Array
>>>>> (
>>>>> )
>>>>> [controller] => users
>>>>> [action] => changePassword
>>>>> [plugin] =>
>>>>> [form] => Array
>>>>> (
>>>>> )
>>>>> [url] => Array
>>>>> (
>>>>> [url] => users/changePassword/3
>>>>> )
>>>>> )
>>>>> After I click on Submit:
>>>>> Array
>>>>> (
>>>>> [pass] => Array
>>>>> (
>>>>> )
>>>>> [named] => Array
>>>>> (
>>>>> )
>>>>> [controller] => users
>>>>> [action] => changePassword
>>>>> [plugin] =>
>>>>> [form] => Array
>>>>> (
>>>>> )
>>>>> [url] => Array
>>>>> (
>>>>> [url] => users/changePassword
>>>>> )
>>>>> )
>>>>> As you can see the "user id" parameter is lost.
>>>>> Any ideas?
>>>>> Thanks in advance.
>>>> ------------------------------------------------------------------------
>>>> No virus found in this incoming message.
>>>> Checked by AVG -http://www.avg.com
>>>> Version: 8.0.175 / Virus Database: 270.8.4/1752 - Release Date: 10/28/2008 10:04 AM
>> >
>>
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - http://www.avg.com
>> Version: 8.0.175 / Virus Database: 270.8.4/1752 - Release Date: 10/28/2008 10:04 AM
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment