Re: Query produced by $this-User-save($this-data); gives error
On Fri, Apr 20, 2012 at 05:31, Mangesh Sathe reach.mangeshsa...@gmail.com wrote: During registration i have email id, user name , password, confirm password in view , all of them are compulsory. but in database other fields like createdBy , newsletter etc are there. When i save form using $this-User-save($this-data); it generates query for only email id, user name , password ( confirm password match validation working fine) . How can i add values to createdBy , newsletter etc. fields? so that insert query will work for all the fields in table. Before you call the save function set the other variables in the array. $this-data['User']['createdBy'] = the value you want to save; $this-data['User']['newsletter'] = of course they want the newsletter And then call save $this-User-save($this-data); This is assuming that you don't have form fields for those parts. If you do, you will have to make sure that they are being passed properly from the form. Check the output of $this-data to make sure they are being set properly. Mike. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Query produced by $this-User-save($this-data); gives error
Always call as first $this-User-create(); //see the API and then either $fieldList = array(...); $this-User-set($this-request-data); $this-User-set('field', 'value'); $this-User-save(null, true, $fieldList); or directly $this-User-save($this-request-data, true, array(...)); Which fields will be saved, it is decided by combination of two factors - which fields are present in data, and which fields are specified in whitelist array. Usage of whitelist (3rd param of Model::save()) is good habit - if form fields are generated by FormHelper and controller uses SecurityComponent, you don't have to worry about form tampering in client's browser, but it is better/safer to tell model about desired fields anyway. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Query produced by $this-User-save($this-data); gives error
Thanks , this worked . On Fri, Apr 20, 2012 at 14:13, stork lubomir.st...@gmail.com wrote: Always call as first $this-User-create(); //see the API and then either $fieldList = array(...); $this-User-set($this-request-data); $this-User-set('field', 'value'); $this-User-save(null, true, $fieldList); or directly $this-User-save($this-request-data, true, array(...)); Which fields will be saved, it is decided by combination of two factors - which fields are present in data, and which fields are specified in whitelist array. Usage of whitelist (3rd param of Model::save()) is good habit - if form fields are generated by FormHelper and controller uses SecurityComponent, you don't have to worry about form tampering in client's browser, but it is better/safer to tell model about desired fields anyway. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- * マンゲシュサテ* * MANGESHSATHE* -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Query produced by $this-User-save($this-data); gives error
+1 for stork on completeness (listing all possibilities) Am Freitag, 20. April 2012 12:47:25 UTC+2 schrieb Mangesh Sathe: Thanks , this worked . On Fri, Apr 20, 2012 at 14:13, stork lubomir.st...@gmail.com wrote: Always call as first $this-User-create(); //see the API and then either $fieldList = array(...); $this-User-set($this-request-data); $this-User-set('field', 'value'); $this-User-save(null, true, $fieldList); or directly $this-User-save($this-request-data, true, array(...)); Which fields will be saved, it is decided by combination of two factors - which fields are present in data, and which fields are specified in whitelist array. Usage of whitelist (3rd param of Model::save()) is good habit - if form fields are generated by FormHelper and controller uses SecurityComponent, you don't have to worry about form tampering in client's browser, but it is better/safer to tell model about desired fields anyway. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- * マンゲシュサテ* * MANGESHSATHE* -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Query produced by $this-User-save($this-data); gives error
Hello all , During registration i have email id, user name , password, confirm password in view , all of them are compulsory. but in database other fields like createdBy , newsletter etc are there. When i save form using $this-User-save($this-data); it generates query for only email id, user name , password ( confirm password match validation working fine) . How can i add values to createdBy , newsletter etc. fields? so that insert query will work for all the fields in table. Thanks in advance, Mangesh Sathe -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php