My (mostly technical) blog

CakePHP: Edit view mysteriously changing to Add on Save validation failure

Posted on: March 25, 2009

I have never been more in need of a proper PHP debugger in my whole life. I have been stuck with a very mysterious behavior with CakePHP for the past 4 hours.

I was editing a model, then saving it. For some reason, my form action was changing from


it was making me go crazy!

After seaching around (finally) I found this:
I came to realize that I have actually omitted the

<?= form->input('id'); ?>

from my edit view because I thought “why the hell do I need to edit the primary key?”

As it turns out, CakePHP needs a field (hidden or not) with the name ID or else it will revert to the ADD form.

Luckily though, it is smart enough to render it as a hidden field.

Google is your friend.

Tags: ,

8 Responses to "CakePHP: Edit view mysteriously changing to Add on Save validation failure"

Your last words “Google is your friend” reminds me of an article I read somewhere before. Was about 30 essential references for developers…

Google was #1 😀

Have you tried FirePHP with Firebug?

Yeah I started using it recently..but I meant a “proper” debugger..that I can put breakpoints and follow through the execution line by line..!

It was happening somewhere automatically in the CakePHP framework source code so I couldn’t determine the reason directly by using FirePHP..

I just is just too odd to find on Google, but I guess I was wrong 😛

Thanks for posting. Wish the manual explained this a bit better.

What’s the last date I can post this to to arrive in time for Christmas? hot models

I’d like to cancel a cheque 16yr Model Nn

I’m training to be an engineer Ls Models Foto

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

Ahmed Sabbour's Facebook profile
March 2009
« Oct   Apr »


RSS StackOverflow

Recently bookmarked

%d bloggers like this: