Re: how to do Multi-Row Edit ?
Update: I've managed to get this article submitted to the Bakery - but I have no idea how long it will take for them to review and publish it. I will wait a week, and if I don't hear anything by then, I'll post it here. Steve T. On Mar 26, 2:36 pm, digital spaghetti [EMAIL PROTECTED] wrote: Absolutly steve, get posting so we can get baking :). I haven't had to do this yet but I know it'll be coming soon. Tane On 3/26/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Another method that was referenced in this group a while back was to use tags like ['model0']['Name'] ['model1']['Name'] Then in your controller, dynamically create a new model for each 'modelX' that you have and validate() it and then save() it. This way you also get the proper validation messages passed back from the model to the view fields. I created a component to automatically convert the findAll() results array to this format for the view, and back to the multiple models and did the saves automatically. All you have to do is a multiModel-get() before your view and then a multModel-save() call to do your saves. I also created a helper to take this model and create the form fields needed to make an editable grid in the view. I tried to create an article in the Bakery for it, but I could not submit it because of the bugs in the Bakery. I may try again - or just post it here if there is interest. Steve Truesdale On Mar 26, 8:57 am, francky06l [EMAIL PROTECTED] wrote: You can use a hack to format the tags using an indice ... such as ['model'][0]['Name'], ['model'][1]['Name] etc ... You can use : 'Model/'.$indice.'][fieldname' into the tag name to produce the above format .. On Mar 26, 5:37 am, cc96ai [EMAIL PROTECTED] wrote: I know how to do in PHP, but I have no idea how to work it on cakePHP e.g. I have a table of products, and I will list all the products in one form , one page, -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total user will input the Qty in the form, and once he submitted into server it will save into invoice database BUt how can cake handle the name in Multi-Row and direction will help . Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP 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: how to do Multi-Row Edit ?
You can use a hack to format the tags using an indice ... such as ['model'][0]['Name'], ['model'][1]['Name] etc ... You can use : 'Model/'.$indice.'][fieldname' into the tag name to produce the above format .. On Mar 26, 5:37 am, cc96ai [EMAIL PROTECTED] wrote: I know how to do in PHP, but I have no idea how to work it on cakePHP e.g. I have a table of products, and I will list all the products in one form , one page, -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total user will input the Qty in the form, and once he submitted into server it will save into invoice database BUt how can cake handle the name in Multi-Row and direction will help . Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP 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: how to do Multi-Row Edit ?
What a timely post! I'm doing the same thing...showing a table of data and allowing the user to edit it. By using this 'hack' will CakePHP handle the insert without any additional considerations? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP 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: how to do Multi-Row Edit ?
You would have to use a custom model to overwrite some functionality (cake 1.x): E.g class MyHtml extends Html { ... function setFormTag($tagValue) { $parts = explode(/, $tagValue); $this-model = $parts[0]; $this-field= array_pop($parts); // We add a class attribute to indicate the index of the model if (count($parts) 1) $this-modelIndex = $parts[1]; else $this-modelIndex = null; } ... function tagValue($fieldName) { $this-setFormTag($fieldName); if ($this-modelIndex !== null) { // This assumes that your data is like so: // data = array('Model'=array(array('Model'=array(/* data */; // Default cake // which can be obtained with $this-data['Model'] = $this- Model-findAll(); if (isset($this-params['data'][$this-model][$this- modelIndex][$this-model][$this-field])) { return h($this-params['data'][$this-model][$this- modelIndex][$this-model][$this-field]); } elseif(isset($this-data[$this-model][$this-modelIndex] [$this-model][$this-field])) { return h($this-data[$this-model][$this-modelIndex] [$this-model][$this-field]); } } else { return parent::tagValue($fieldName); } } ... } In your view, you can then do the following: ?php foreach ($this-data['Product'] as $i = $rec) : ? tr td?= $rec['Product']['name'] ?/td td?= $myhtml-input(Product/$i/qty) ?/td /tr ?php endforeach; ? Please note that this code was not tested. Also, the id of your input will become Product0Qty, Product1Qty, etc. Please contribute your final solution. There are many with the same issue :S. Thanks. Dimitry Z --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP 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: how to do Multi-Row Edit ?
I cant generate this kind of format ['model'][0]['Name'], ['model'][1] ['Name] but I m trying to put the id into tag name $html-input(product/qty.$product['Product']['id']); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP 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: how to do Multi-Row Edit ?
Another method that was referenced in this group a while back was to use tags like ['model0']['Name'] ['model1']['Name'] Then in your controller, dynamically create a new model for each 'modelX' that you have and validate() it and then save() it. This way you also get the proper validation messages passed back from the model to the view fields. I created a component to automatically convert the findAll() results array to this format for the view, and back to the multiple models and did the saves automatically. All you have to do is a multiModel-get() before your view and then a multModel-save() call to do your saves. I also created a helper to take this model and create the form fields needed to make an editable grid in the view. I tried to create an article in the Bakery for it, but I could not submit it because of the bugs in the Bakery. I may try again - or just post it here if there is interest. Steve Truesdale On Mar 26, 8:57 am, francky06l [EMAIL PROTECTED] wrote: You can use a hack to format the tags using an indice ... such as ['model'][0]['Name'], ['model'][1]['Name] etc ... You can use : 'Model/'.$indice.'][fieldname' into the tag name to produce the above format .. On Mar 26, 5:37 am, cc96ai [EMAIL PROTECTED] wrote: I know how to do in PHP, but I have no idea how to work it on cakePHP e.g. I have a table of products, and I will list all the products in one form , one page, -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total user will input the Qty in the form, and once he submitted into server it will save into invoice database BUt how can cake handle the name in Multi-Row and direction will help . Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP 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: how to do Multi-Row Edit ?
Absolutly steve, get posting so we can get baking :). I haven't had to do this yet but I know it'll be coming soon. Tane On 3/26/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Another method that was referenced in this group a while back was to use tags like ['model0']['Name'] ['model1']['Name'] Then in your controller, dynamically create a new model for each 'modelX' that you have and validate() it and then save() it. This way you also get the proper validation messages passed back from the model to the view fields. I created a component to automatically convert the findAll() results array to this format for the view, and back to the multiple models and did the saves automatically. All you have to do is a multiModel-get() before your view and then a multModel-save() call to do your saves. I also created a helper to take this model and create the form fields needed to make an editable grid in the view. I tried to create an article in the Bakery for it, but I could not submit it because of the bugs in the Bakery. I may try again - or just post it here if there is interest. Steve Truesdale On Mar 26, 8:57 am, francky06l [EMAIL PROTECTED] wrote: You can use a hack to format the tags using an indice ... such as ['model'][0]['Name'], ['model'][1]['Name] etc ... You can use : 'Model/'.$indice.'][fieldname' into the tag name to produce the above format .. On Mar 26, 5:37 am, cc96ai [EMAIL PROTECTED] wrote: I know how to do in PHP, but I have no idea how to work it on cakePHP e.g. I have a table of products, and I will list all the products in one form , one page, -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total -Name, Desc, Qty, Price, Total user will input the Qty in the form, and once he submitted into server it will save into invoice database BUt how can cake handle the name in Multi-Row and direction will help . Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP 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: how to do Multi-Row Edit ?
in your provided code, we might to update helper.php var $tags = array('link' = 'a href=%s %s%s/a', 'mailto' = 'a href=mailto:%s; %s%s/a', 'form' = 'form %s', 'input' = 'input name=data[%s][%s] %s/', 'hidden' = 'input type=hidden name=data[%s][%s] %s/', I m not sure thats good idea or not --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP 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: how to do Multi-Row Edit ?
CC96AI, You're right about modifying the tag templates. There would have to be more changes than the ones i mentioned above. However, it's a starting point :). As for it being a good idea, you can implement your own tags. Since you're subclassing HtmlHelper you can redefine the $tags class attribute to have your own templates. Also, you would need to modify the rendering of those templates. Dim On Mar 26, 3:57 pm, cc96ai [EMAIL PROTECTED] wrote: in your provided code, we might to update helper.php var $tags = array('link' = 'a href=%s %s%s/a', 'mailto' = 'a href=mailto:%s; %s%s/a', 'form' = 'form %s', 'input' = 'input name=data[%s][%s] %s/', 'hidden' = 'input type=hidden name=data[%s][%s] %s/', I m not sure thats good idea or not --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP 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 -~--~~~~--~~--~--~---