Re: (views) Redirect where i came from
Well, i forgot a problem. Now, i have my global add-function in my appController. But some add-views have drop-down fields to show the available foreign- keys. They additional use this code: [code] $this-set('foreignKey', $this-Model1-Model2-find('list')); [/code] So, can i extend the concerning controllers with this code or must i copy the complete add function (with additional code) to this controllers? Greetings. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
You implement the add function in the controller, that requires additional information, then just make sure that you call the parent add function ( using parent::add(...) ) in the app controller. Enjoy, John On Mar 1, 2:36 pm, sebb86 kahlc...@googlemail.com wrote: Well, i forgot a problem. Now, i have my global add-function in my appController. But some add-views have drop-down fields to show the available foreign- keys. They additional use this code: [code] $this-set('foreignKey', $this-Model1-Model2-find('list')); [/code] So, can i extend the concerning controllers with this code or must i copy the complete add function (with additional code) to this controllers? Greetings. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
John Thanks again!!! You solved it. :) Here is the code from one of my add-functions, which has a drop-down field with foreign-key elements. [code] function add() { parent::add(); $this-set('staffs', $this-HardwareUnit-Staff-find('list')); $this-set('rooms', $this-HardwareUnit-Room-find('list')); $this-set('hardwareGroups', $this-HardwareUnit-HardwareGroup- find('list')); $this-set('hardwareTypes', $this-HardwareUnit-HardwareType- find('list')); } [/code] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
Paul In my inventory-management, every table/model has the need of an add- function. The models are, for example: rooms, locations, hardware_groups, hardware_units, mobile_radio_units, ports ... and so on. Furthermore, the add functions are equal to each other, expect, if there is an foreign-key inside. So i'd like to create the add-function in the app_controller. Your code works, thanks! :) My last question is, do you know how to make this dynamical, because the code has to be inside the add_controller. [code] function add() { if(!empty($this-data)) { if($this-{$this-modelClass}-save($this-data)) { $this-Session-setFlash('Speichervorgang erfolgreich!'); $this-redirect($this-data[{$this-modelClass}]['referer']); } } if (!$this-data[{$this-modelClass}]['referer']) { $this-data[{$this-modelClass}]['referer'] = $this-referer(); } } [/code] I've tryed: {$this-modelClass} I think the result of this is only the [code]class[/code] but i need [code]'class'[/code]. And again, thank you very much for helping me in nearly all me topics! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
You only use {$this-modelClass} when you want to use the model instance. In you data array, just use $this-modelClass without the curly brackets! Enjoy, John On Mar 1, 8:53 am, sebb86 kahlc...@googlemail.com wrote: Paul In my inventory-management, every table/model has the need of an add- function. The models are, for example: rooms, locations, hardware_groups, hardware_units, mobile_radio_units, ports ... and so on. Furthermore, the add functions are equal to each other, expect, if there is an foreign-key inside. So i'd like to create the add-function in the app_controller. Your code works, thanks! :) My last question is, do you know how to make this dynamical, because the code has to be inside the add_controller. [code] function add() { if(!empty($this-data)) { if($this-{$this-modelClass}-save($this-data)) { $this-Session-setFlash('Speichervorgang erfolgreich!'); $this-redirect($this-data[{$this-modelClass}]['referer']); } } if (!$this-data[{$this-modelClass}]['referer']) { $this-data[{$this-modelClass}]['referer'] = $this-referer(); } } [/code] I've tryed: {$this-modelClass} I think the result of this is only the [code]class[/code] but i need [code]'class'[/code]. And again, thank you very much for helping me in nearly all me topics! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
John You only use {$this-modelClass} when you want to use the model instance. Thats it. Thanks very much! :) If someone other wants to use this, here is my final code (add function in app_controller): [code] function add() { if(!empty($this-data)) { if($this-{$this-modelClass}-save($this-data)) { $this-Session-setFlash('Speichervorgang erfolgreich!'); $this-redirect($this-data[$this-modelClass]['referer']); } else { $this-Session-setFlash('Speichervorgang fehlgeschlagen!'); } } if (!$this-data[$this-modelClass]['referer']) { $this-data[$this-modelClass]['referer'] = $this-referer(); } } [/code] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
John You only use {$this-modelClass} when you want to use the model instance. Thats it. Thanks very much! :) If someone other wants to use this, here is my final code (add function in app_controller): [code] function add() { if(!empty($this-data)) { if($this-{$this-modelClass}-save($this-data)) { $this-Session-setFlash('saved!'); $this-redirect($this-data[$this-modelClass]['referer']); } else { $this-Session-setFlash('fail!'); } } if (!$this-data[$this-modelClass]['referer']) { $this-data[$this-modelClass]['referer'] = $this-referer(); } } [/code] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
The code I gave you for the controller is supposed to be called the first time the form is shown so should not go into the area that only runs when $this-data exists. Example [controller code] function add() { if(!empty($this-data)) { if($this-HardwareGroup-save($this-data)) { $this-Session-setFlash('saved'); $this-redirect($this-data['HardwareGroup']['referer']); } } if (!$this-data['HardwareGroup']['referer']) { $this-data['HardwareGroup']['referer'] = $this-referer(); } } [/controller code] Got no idea what your now working on by adding an add method into your app_controller, seems wrong to me. Paul Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
if (!$this-data['HardwareGroup']['referer']) { $this-data['HardwareGroup']['referer'] = $this-referer(); } Needs to go into your controllers add/edit methods and is simply doing the job of checking if there is already a referer value in the data array(i.e. the form has been submitted and there were errors so it's been shown again). If it is the first time the form has been requested, it inserts the forms referring url into the data array and you need to include that value in your add/edit form (hidden field as shown above) for it to be passed back to the controller after submitting the form. If this $this-data['HardwareGroup']['referer'] is being set as $this- referer() every time then you haven't included the value in your form. Paul. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
Paul, hmm, it dont works :/ Could you look at the source please? And should i pass something to the view and write it in the brackets after function add? [controller code] function add() { if(!empty($this-data)) { if($this-HardwareGroup-save($this-data)) { $this-Session-setFlash('saved'); if (!$this-data['HardwareGroup']['referer']) { $this- data['HardwareGroup']['referer'] = $this-referer(); } $this-redirect($this-data['HardwareGroup']['referer']); } } } [/controller code] [some view code] ?php echo $form-create('HardwareGroup'); echo $form-input('HardwareGroup.referer', array('type'='hidden')); echo $form-input('description'); echo $form-end('Save'); ? [/some view code] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
Well, i have a continative problem. Now, i have my global add-function in my appController. But some add-views have drop-down fields to show the available foreign- keys. So how can i extend the concerning controllers with my foreign-key drop-down field code? [code] $this-set('foreignKey', $this-Model1-Model2-find('list')); [/code] Is it possible to extend my controllers? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
Well, when i write down the complete add-function again (with additional foreign-key content) in the controllers, that need this additional content, it seems to work. But is it possible, to only add the foreign-key content to the controllers instead of the complete function? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
Hello, thanks for your help!!! But with this code, if i copyed it on the right places, i every time go back to the add view :/ But the destination should be the view where i came from. Hmm, or it's my mistake. Could you tell me, where i exactly have to post this code?: if (!$this-data['HardwareGroup']['referer']) { $this-data['HardwareGroup']['referer'] = $this-referer(); } Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
If you've just added a HardwareGroup, then surely you are then going to add some Hardware into it and as such being taken to view that group is going to save you time as any add link in that view would preselect the newly created HardwareGroup. If you want to do it your way then in the HardwareGroup controller have the following if (!$this-data['HardwareGroup']['referer']) { $this-data['HardwareGroup']['referer'] = $this-referer(); } Then in your add form add a hidden field $form-input('HardwareGroup.referer', array('type'='hidden')); Then after a successful save in the controller $this-redirect($this-data['HardwareGroup']['referer']); Paul. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
$this-redirect(array('action'='view', $this-ModelName-id)); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
Hello, thanks, but i know this code. The problem is, that i have to redirect dynamical to the view, where i came from, because you can access some views from many other views. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
Not sure I understand what you want then? It seems perfectly logical that after editing record A to redirect to record A's view. In what situation would you be viewing record A and be able to directly go to edit record B then be taken back to viewing record A. $this-redirect($this-referer()) takes you back to the previous page which when submitting a form is the form you just submitted, if you want to go to the page before that you will have to pass the value of $this-referer() with the form data in a hidden field. HTH Paul. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: (views) Redirect where i came from
Oh sorry, i don't want to edit, i want to add. I create an inventory management. When i'm in view hardware units, it's handy to add (via global drop down menu) a hardware group. This helps me to save time because without that global drop-down, i have to go to view hardware groups, then add once, then go back to hardware units. Hope thats understandable? Could you create a short example please, i dont know how to solve that :/ Thanks for your help! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en