Update Form Not Posting

Hey all, so I’m fairly new to Yii and have recently run into a bit of an issue with my code. I used Gii to generate my controllers, models, views etc. and then made changes to them. Anyway, in the Update function of my controller this if test keeps failing when I hit “Save” on the update form.


if(isset($_POST['Tasks']))

It’s currently failing for all of my controllers that use forms and I don’t have any idea what’s happening to it. If anyone has any tips that’d be greatly appreciated.

PHP Version 5.3.2

Apache 2.2

If you need to see more of my code to be able to help, I’ll be checking this thread pretty frequently.

Thanks a ton,

Jake

What’s the output of




var_dump($_POST);



after you post ?

array(2) { [“ContactParent”]=> array(8) { [“firstName”]=> string(4) “John” [“lastName”]=> string(5) “Smith” [“phone”]=> string(12) “831-555-5555” [“email”]=> string(14) "john@smith.com" [“address”]=> string(0) “” [“visibility”]=> string(1) “1” [“assignedTo”]=> string(9) “jvalerian” [“backgroundNotes”]=> string(0) “” } [“yt0”]=> string(4) “Save” }

Didn’t think of that… but it looks like it returns legitimate information, but when I checked to see if the isset was passing, it wasn’t.

Doesn’t look like you have a form element called Tasks looking at that POST data.

well that’s your mistake.

you check for :




if(isset($_POST['Tasks']))



But your array doesn’t have the Tasks index defined, it has: ContactParent and yt0 .

So i guess you’ve mistaken the model and you need to check against:




if(isset($_POST['ContactParent']))



Please let me know if it helps, else, please post here the entire actionUpdate() method.

Also, please use [ code ][ /code ](no spaces between[ and ] ) tags to embed your php code so that i can easily read it.

You’re checking for the presence of $_POST[‘Tasks’], which isn’t set.

You need to be checking for


$_POST['ContactParent']

For any part of a controller that is executed only when a POST variable is present, make sure it’s actually there!

Off-topic: The yii forum grows so nice :X

Thanks a bunch guys. I actually accidentally did the var_dump from Contacts and not Tasks, but the ContactParent makes sense for what I wrote. Thanks so much!