|
I have a jquery page and am using load() function to load objects to
that page but now i need to load an edit form with the existing values to the page. do i load the view of the object and then use requestAction to get the existing data? -- 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 [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php |
|
To load the form with AJAX, call the edit action, passing the ID, with
JQuery's load(). Use the same URL that you would in a link, in other words. If you only want the form to be loaded, and not the regular edit view, put the form itself inside an element. The add & edit views then load the form with $this->element(). Use a switch to branch based on the action: form.ctp: switch ($this->params['action']) { case 'admin_edit': echo $this->Form->create('Post', array('action' => 'edit')); echo $this->Form->hidden('Post.id'); break; case 'admin_add': default: echo $this->Form->create('Post', array('action' => 'add')); } // etc. In the controller, test to see if it's an AJAX request. If it is, set the viewPath to point to the elements directory, then render just the form, not the full edit view. function beforeFilter() { parent::beforeFilter(); if ($this->RequestHandler->isAjax()) { Configure::write('debug', 0); $this->layout = 'ajax'; } } public function edit($id = null) { // other stuff ... if ($this->RequestHandler->isAjax()) { $this->viewPath = 'elements'.DS.'your_controller_name'; $this->render('form'); } } On Wed, May 23, 2012 at 6:06 PM, femi oni <[hidden email]> wrote: > I have a jquery page and am using load() function to load objects to > that page but now i need to load an edit form with the existing values > to the page. do i load the view of the object and then use > requestAction to get the existing data? > > -- > 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 > [hidden email] 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 [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php |
| Powered by Nabble | Edit this page |
