Monday, September 26, 2011

Re: Model update modifies fields not present in data array

Is the update of the enabled field happening as part of the same SQL
query or a separate one? Are you sure you have not got a callback
(beforeSave or afterSave) running which is doing this?

HTH, Paul

On Sep 25, 7:20 pm, dtemes <dte...@gmail.com> wrote:
> More information, If i don't provide a value for fields that have a
> default value in the database, the fields are modified and they take
> the database default value.
>
> For instance I have a reset password action that takes data from a
> form with just the user id and password. The data array only has id
> and password.
>
> Submitting the form changes the user password, but the user model has
> a enabled field, with a default value of 0. In the sql query I can see
> that cake is doing an update of the password fields but also of the
> enabled field.
>
> Using cake 1.3.5
>
> On 25 sep, 15:31, dtemes <dte...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I ahev to related models, group and user, and I have a form to update
> > user data from the groups controller, previously to the User->Save i
> > read some information from the current user, the code is something
> > like:
>
> > $this->Group->User->read->($this->Auth->user('id'));
> > .
> > .
> > .
> > $this->Group->User->Save($this->data);
>
> > As a result if the current user value of fieldX is 123, then the
> > fieldX of the user being updated takes the value 123, but there is no
> > such fieldX in the $this->data
>
> > One way to avoid this is by doing a  $this->Group->User->read(null,
> > $this->data['User']['id']); but either there is something wrong in the
> > cake implementation of the save function or most probably I am missing
> > something.
>
> > Any ideas?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: