Patrick Guinness
Patrick Guinness

Reputation: 397

cakephp - arriving at an edit form via a post

I want to hide the id of the record I want to edit from my users, so to get to the edit (eg) widget form I make users click a link which submits a form that posts the id to my edit action, instead of passing it as a parameter.

In the action, I then use the id to fill up $this->request->data with the widget's info so that it appears in the inputs already when the form is rendered.

The problem is, that when cake detects the Model name and the valid id, then Form helper creates a form which submits to widgets/edit/1 which causes me a problem because I want it to go to widgets/edit (without the id).

If I just code the start of the form manually then I can't take advantage of the defaults formats for the rest of the inputs

Is there a better way of doing this? There must be!

Upvotes: 0

Views: 45

Answers (2)

sdagli
sdagli

Reputation: 121

My suggestion dont use

$this->Form->create('User', array('url' => '/users/edit));

Do this like

$this->Form->create('User', array('url' => array('controller' => 'users', 'action' => 'edit')));

Upvotes: 1

noslone
noslone

Reputation: 1289

You can provide the url in $this->Form->create();

Try following code:

$this->Form->create('User', array('url' => '/users/edit'));

Upvotes: 0

Related Questions