Re: FindAll and multi-record form "convention over configuration" right?
So hacking away I go... from the latest svn code in cake/libs/view/helper.php I changed the function value() line 581,582,583 I copied to make another test looking for [id][model] [field] Then in cake/libs/view/view.php I changed the function entity() line 557,558 I rearrange the order to put the modelID before the ife() statement. Don't know what side-effects this will have, but ... looks like it creates the multi-record form directly from the data fetched from findAll. -Troy On May 24, 8:52 am, troyp <[EMAIL PROTECTED]> wrote: > I'm just learning and I don't get it. I am trying to follow the > concept of convention over configuration and finding issues. > > I want a multi-record form so I perform a findAll(...) to get the > data. > > Then I make the form calls > > echo $form->input("$i.time"); > echo $form->input("$i.category_id"); > > The problem is that it appears that findAll is using a different > keypath to create the array than the FormHelper is assuming. > > findAll returns an array of this form {n}.{Model}.{Field} > > while FormHelper is assuming {Model}.{n}.{Field} > > Seems like a terrible waste of time (and code) to have me make > another copy of the data with a different keypath. I must be missing > something. > > Any suggestions would be greatly appreciated. > > Thanks, > Troy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: FindAll and multi-record form "convention over configuration" right?
Thanks for the reply. That makes sense to loop through the data, the problem seems to be in how the form helper is rendering the name field. I tried your suggestions and here is what I got ... ---code foreach ($this->data as $row) { echo $form->hidden('Entry.id'); --- ---html That isn't where the data is located. It would work if the name was data[0][Entry][id]. I tried a variation where I have a counter variable $i ranging from 0 to 2 echo $form->hidden("$i.Entry.id"); /* yes the $i is there to convert is into the index */ renders wrote: > On May 24, 2008, at 8:52 PM, troyp wrote: > > > > > I'm just learning and I don't get it. I am trying to follow the > > concept of convention over configuration and finding issues. > > > I want a multi-record form so I perform a findAll(...) to get the > > data. > > > Then I make the form calls > > > echo $form->input("$i.time"); > > echo $form->input("$i.category_id"); > > Just to make sure, there shouldn't be a variable sign over there. You > only need to put 'Model.field', so by putting $form- > >input('Product.name'), it will automatically maps to name field in > your products table. > > > The problem is that it appears that findAll is using a different > > keypath to create the array than the FormHelper is assuming. > > > findAll returns an array of this form {n}.{Model}.{Field} > > > while FormHelper is assuming {Model}.{n}.{Field} > > You only need to change your foreach statement. If the array is > resulting {n}.{Model}.{field}, then you use foreach ($var as $v), then > inside your foreach statement you call it by $v['Model']['field'] > > But, if the resulting array is {Model}.{n}.{Field}, you use foreach > ($var['Model'] as $v), then you call it by $v['Field'] inside the > statement. > > > Seems like a terrible waste of time (and code) to have me make > > another copy of the data with a different keypath. I must be missing > > something. > > > Any suggestions would be greatly appreciated. > > > Thanks, > > Troy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: FindAll and multi-record form "convention over configuration" right?
> echo $form->input("$i.time"); > echo $form->input("$i.category_id"); Have you tried, echo $form->input("ModelName.field_name.$i"); I believe this will return everything as an array on the backend that you can loop through. Mind you, you may have to fill the value in for those manually. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: FindAll and multi-record form "convention over configuration" right?
For my project I did create 2 convert functions: One dat converts the array returned from findAll methods to {Model}.{n}.{Field}, and one visa versa. I've made this on 1.2.6311 and don't know what changes have been regarding this but still works for me... I too had some problems with the formhelper not finding correct data, or not showing validation errors, but with the array rewrite stuff it does work like it should be. Only convention is that the name of your input fields should be in the same path format as the array in $this- >data (like "MyModel.5.category_id") Marcel On 24 mei, 15:52, troyp <[EMAIL PROTECTED]> wrote: > I'm just learning and I don't get it. I am trying to follow the > concept of convention over configuration and finding issues. > > I want a multi-record form so I perform a findAll(...) to get the > data. > > Then I make the form calls > > echo $form->input("$i.time"); > echo $form->input("$i.category_id"); > > The problem is that it appears that findAll is using a different > keypath to create the array than the FormHelper is assuming. > > findAll returns an array of this form {n}.{Model}.{Field} > > while FormHelper is assuming {Model}.{n}.{Field} > > Seems like a terrible waste of time (and code) to have me make > another copy of the data with a different keypath. I must be missing > something. > > Any suggestions would be greatly appreciated. > > Thanks, > Troy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: FindAll and multi-record form "convention over configuration" right?
On May 24, 2008, at 8:52 PM, troyp wrote: > > I'm just learning and I don't get it. I am trying to follow the > concept of convention over configuration and finding issues. > > I want a multi-record form so I perform a findAll(...) to get the > data. > > Then I make the form calls > > echo $form->input("$i.time"); > echo $form->input("$i.category_id"); Just to make sure, there shouldn't be a variable sign over there. You only need to put 'Model.field', so by putting $form- >input('Product.name'), it will automatically maps to name field in your products table. > The problem is that it appears that findAll is using a different > keypath to create the array than the FormHelper is assuming. > > findAll returns an array of this form {n}.{Model}.{Field} > > while FormHelper is assuming {Model}.{n}.{Field} > You only need to change your foreach statement. If the array is resulting {n}.{Model}.{field}, then you use foreach ($var as $v), then inside your foreach statement you call it by $v['Model']['field'] But, if the resulting array is {Model}.{n}.{Field}, you use foreach ($var['Model'] as $v), then you call it by $v['Field'] inside the statement. > Seems like a terrible waste of time (and code) to have me make > another copy of the data with a different keypath. I must be missing > something. > > Any suggestions would be greatly appreciated. > > Thanks, > Troy > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
FindAll and multi-record form "convention over configuration" right?
I'm just learning and I don't get it. I am trying to follow the concept of convention over configuration and finding issues. I want a multi-record form so I perform a findAll(...) to get the data. Then I make the form calls echo $form->input("$i.time"); echo $form->input("$i.category_id"); The problem is that it appears that findAll is using a different keypath to create the array than the FormHelper is assuming. findAll returns an array of this form {n}.{Model}.{Field} while FormHelper is assuming {Model}.{n}.{Field} Seems like a terrible waste of time (and code) to have me make another copy of the data with a different keypath. I must be missing something. Any suggestions would be greatly appreciated. Thanks, Troy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---