As I understand it, setAction() is used specifically to keep any data (you stay in the same request). To redirect to the index action you should try redirect() which creates a whole new request and any data will be "lost" unless it is session data, of-course. Try that, hopefully things should work as you expect it.
Redirecting does create some overhead which may be something you would want to limit on an extremely busy site but unless you work for Mozilla don't worry about that (yet). /Martin On Jan 14, 12:00 pm, WebbedIT <[email protected]> wrote: > I ask this as I am using multiple Ajax calls, including form > submission, in a modal window so I am not reloading the whole page > after a form is posted. > > The problem I face is after I add/edit a record and redisplay the > index view (using $this->setAction() to re-route to index action), > when I access add/edit again $this->data gets repopulated with the > previously posted data and rather than display the form the add/edit > action processes the request with the previous data. > > I have tried unsset($this->data) which is pointless as my index action > resets this anyway, and I have also tried unsset($_POST) to no > avail. > > I thought that each Ajax request was unique so I am confused as to how > previous POST data is available in subsequent add/edit requests?!? > Can anyone shed light on this? > > For reference I am using ModalBox using a javascript call from onclick > events as follows: > > $html->link( > 'New Telephony Number', > array( > 'action'=>'add', > $this->data['Parent']['parent_name'], > $this->data['Parent']['parent_id']), > array( > 'title'=>'New Telephony Number', > 'onclick'=>'Modalbox.show(this.href, {title: this.title}); return > false;') > ); > > To submit a form I replace $form->end() with my own HTML as follows: > > <div class='submit'><input type="submit" value="Submit" > onclick="Modalbox.show('/cake/TelephonyNumbers/add/<?php echo > $this->data['TelephonyNumber']['parent_model']."/".$this->data > > ['TelephonyNumber']['parent_id']; ?>', {title: 'Sending data', params: > Form.serialize('TelephonyNumberAddForm'), method: 'post'}); return > false;" /></div> > > I did ask this from another angle yesterday and got no luck, so I am > trying again from a slightly different angle. Previous post link ... > > http://groups.google.com/group/cake-php/browse_thread/thread/e36664ce... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
