Quick tip for the form helper in CakePHP when editing

While working on my latest crazy idea, I was testing the edit function of a particular section and realized something alarming:

If I had an error while editing, the form helper was changing my /edit/id form URL to /add!

I could not for the life of me figure out what the problem was. After an hour of various curses and attempts to correct the issue, I stumbled across this little bit of information:

You need to add a hidden id field with the id for the record as the value in order for the edit URL to persist. D’oh!

I simply added this to all my edit views and voila! It worked! Hopefully this will help someone else 🙂

Advertisements
Previous Post
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: