@ShadowCross: That's it! I don't rely on the book as much as I used to (there is a lesson to be learned here) ... I could have saved myself a lot of tinkering. Thanks so much for the help and getting me pointed in the right direction.
- ED On Sat, Apr 2, 2011 at 11:39 PM, <[email protected]> wrote: > Today's Topic Summary > > Group: http://groups.google.com/group/cake-php/topics > > - You favorite IDE/ Dev Setup? <#12f19719e9b0773c_group_thread_0> [1 > Update] > - Euromark function guaranteeFields($requiredFields, $data = null) > {<#12f19719e9b0773c_group_thread_1>[2 Updates] > - Paginate pre-ordered list <#12f19719e9b0773c_group_thread_2> [1 > Update] > > Topic: You favorite IDE/ Dev > Setup?<http://groups.google.com/group/cake-php/t/83f01effcc10dc7> > > huoxito <[email protected]> Apr 02 07:24PM -0700 > ^<#12f19719e9b0773c_digest_top> > > Ubuntu > Vim (still learning but already useful for me) > Gedit > Git > Shell > Apache > Mysql > > > > Topic: Euromark function guaranteeFields($requiredFields, $data = null) > { <http://groups.google.com/group/cake-php/t/fb6a390a0056ddf5> > > euromark <[email protected]> Apr 02 06:13PM -0700 > ^<#12f19719e9b0773c_digest_top> > > it is not possible > > the controller has no direct link to the form helper > especially not after a post (and therefore BEFORE the form is rendered > again). > controller + model are finished before the view even starts to render. > > you would need to embed the keys as a hidden field in the form itself > (+ hash etc to disallow any modifications). > but then you could just as well use the security component and you > would be already done. > > so i dont see a point in that. > i agree that it can be a pain in the but. > in some rare occasions you could use blacklisting (especially if you > only want to forbid 1 field of 50 allowed fields). > in other occasions you would store those field names in a (long?) > array in the model and simply use it in the controller > $this->Model->allowedFieldsForEdit > etc > > either way linking the form helper / form inputs to the model logic > can probably do more harm than good. > i would think about which fields are allowed and manually pass them to > the set/save methods. using the model arrays to store the fields will > also ensure that after an update of the schema you got all field names > in a single place. less likely you will forget to add/delete fields. > > > > > > > "Krissy Masters" <[email protected]> Apr 02 10:56PM -0230 > ^<#12f19719e9b0773c_digest_top> > > Right on. Was only curious since Security create a hash based on the > fields > I figured there must be some way to do the same thing and use it for > whatever reason. > > Thanks for the info all the same. > > K > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf > Of euromark > Sent: Saturday, April 02, 2011 10:43 PM > To: CakePHP > Subject: Re: Euromark function guaranteeFields($requiredFields, $data = > null) { > > it is not possible > > the controller has no direct link to the form helper > especially not after a post (and therefore BEFORE the form is rendered > again). > controller + model are finished before the view even starts to render. > > you would need to embed the keys as a hidden field in the form itself > (+ hash etc to disallow any modifications). > but then you could just as well use the security component and you > would be already done. > > so i dont see a point in that. > i agree that it can be a pain in the but. > in some rare occasions you could use blacklisting (especially if you > only want to forbid 1 field of 50 allowed fields). > in other occasions you would store those field names in a (long?) > array in the model and simply use it in the controller > $this->Model->allowedFieldsForEdit > etc > > either way linking the form helper / form inputs to the model logic > can probably do more harm than good. > i would think about which fields are allowed and manually pass them to > the set/save methods. using the model arrays to store the fields will > also ensure that after an update of the schema you got all field names > in a single place. less likely you will forget to add/delete fields. > > > > grab all the fields your form has before rendering it > > > $form_fields = ??? somefunction to grab all your fields > > > Then use an array / !in_array / arrys_keys to keep / exclude ones > that > are > > > K > > > -----Original Message----- > > From: [email protected] [mailto:[email protected]] On > Behalf > > <[email protected]> wrote: > > > Reading the bit about making fields required in a form so a user > can not > > > firebug them out and thought is there a way to manually grab the > names > of > > > would be trauma. (but writing the names and updating the model in > the > > > future, spelling....so on) > > > > Security component does something with all the names to makes it > hash > no? > > > > Anyone have any ideas? Here is a link to his excellent idea incase > anyone > > ); > > > -- > > Our newest site for the community: CakePHP Video > Tutorialshttp://tv.cakephp.org > > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > > [email protected] For more options, visit this > group > athttp://groups.google.com/group/cake-php > > -- > 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 > [email protected] For more options, visit this > group at > http://groups.google.com/group/cake-php > > > > Topic: Paginate pre-ordered > list<http://groups.google.com/group/cake-php/t/e30c76ca2514cd5e> > > ShadowCross <[email protected]> Apr 02 06:25PM -0700 > ^<#12f19719e9b0773c_digest_top> > > So is this correct? > > The 'likes' table has one record for each time a User is liked (i.e. > if 50 people have indicated that they like the User with user_id = 23, > then there are 50 records in the 'likes' table with user_id = 23), and > > User hasMany Like > Like belongsTo User > > If so, have you considered using the counterCache option of the > belongsTo definition? (see: http://book.cakephp.org/view/1042/belongsTo > ). > Basically, with the counterCache, any insert/update/delete in Model > (in this case, Like), will automatically update the designated field > (default: like_count) in the Model that it belongsTo (User) with the > number of related rows. You can then use the field (User.like_count) > in the 'order' option of Controller::paginate. > > > > > -- > 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 > [email protected] For more options, visit this group > at http://groups.google.com/group/cake-php > -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
