Jump to content

[SOLVED] cakephp and checkboxs


cytech

Recommended Posts

Hello,

 

I'm a little confused(surprise) about how this exactly works... I am working on someones cakephp code(which is great fun  >:( ) and am trying to understand how some things work.

 

There is a registration form, easy enough, now I added a new checkbox to the form and also added the new element in the db.

 

When I submit the form all the variables come through (I did a dump of $this->data['User']) including my new checkbox name "Pd" with a value of 1 (checked). However; the database field remains 0, no matter what I do I can't get that field to change to one.

 

Now, the code is using the generic ->save function. Should I be looking somewhere to see if the fields are specified? Like only save these fields and no others? Or, is there something else I should try to debug?

 

Any advice would be very helpful.

Link to post
Share on other sites

I would suggest first check your data and forms with the scaffolding feature cake has.  This should allow you to quickly troubleshoot if you have a problem with your logic or relationships. It is hard to answer your question without seeing more of your application.

Link to post
Share on other sites

Hello,

 

I will try to check out the scaffolding, whats weird is if I dump the data that is being passed to the "save" function, it shows my new variable there fine with a 1 (1=checked). It also saves the other information, so Its not causing a mysql error or anything. Looks like the new field is just being ignored hehe

 

Thanks for some direction, I will try to dump that out and see what happens.

Link to post
Share on other sites

Okay... I have a bit more info now...

 

If found where they had the global save function (model_php5.php).

 

There is a function in here called hasField().

 

Now, for some reason the new element I created into the database will not get by this function.

 

So upon further inspection I noticed the hasField function uses $this->_tableInfo within its in_array check. Now, if I var_dump $this->_tableInfo I notice ALL the fields from that table are there but NOT the new one I created, in fact none of the new fields I create show up.

 

My first thought was, great I'm not using the same db or table, but the entry goes in to the right table and db, its just not recognizing the new fields I add.

 

So, with that said is there an array setup somewhere to say include only these types of fields from this table? or anything like that?

 

Any advice is GREATLY appreciated :)

Link to post
Share on other sites

Well figured it out with some help... Cakephp had stored cached versions of the database and was using these cached versions to validate the fields on the form. Hence none of my new fields where used when saving. Gotta love it lol

 

So I guess the moral of the story, checked cached versions of the db since cakephp I guess does  this lol.

 

 

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.