|
|
Subject: Re: Redirect after an edit operation in a paginated view - msg#00588
List: CakePHP
On Mar 9, 11:26 am, Danny Lieberman <onlyj...@xxxxxxxxx> wrote:
> This would seem to be a trivial task. I have a list of paginated
> rows. I want to be able to click on an edit operation on a
> particular page > 1 and return to the same page. I save the referer
> on entry to the function and redirect to the saved referer after the
> database save operation - but the controller always returns to the
> controller index method no matter what the user chooses.
>
> I'm running in production mode - perhaps this is related to debug=0?
>
> Here is the code:
> function fu($id = null) {
> $refer = Controller::referer(); // save the calling
> page
> if (!$id && empty($this->data)) {
> $this->Session->setFlash(__('Invalid Contact',
> true));
> $this->redirect(array('action'=>'index'));
> }
> echo$refer;
> if (!empty($this->data)) {
> if ($this->Contact->save($this->data)) {
> $this->Session->setFlash(__('The
> Contact has been saved', true));
> // $this->redirect(array
> ('action'=>'index'));
> $this->redirect($refer); // redirect
> back to the calling page after save
> } else {
> $this->Session->setFlash(__('The
> Contact could not be saved. Please, try again.', true));
> }
> }
> if (empty($this->data)) {
> $this->data = $this->Contact->read(null, $id);
> }
> $this->set('contact', $this->Contact->read(null,
> $id));
>
> Looks like something really stupid is breaking this but I cant figure
> out what
>
> Danny
Try this logic:
In the controller:
if (!$this->data) {
$this->set('referer', $this->referer($default));
} else {
if ($this->Model->save()) {
$this->redirect ($this->data['_App']['referer']);
}
}
in the view:
...
echo $form->input('_App.referer', array('value' => $referer, 'type' =>
'hidden'));
...
Personally, I always add a referer to all forms to use for exactly the
purpose you highlight.
hth,
AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: Accordion
Did you guys try to make it work in a simple html document? If you
copy his whole source code into an html doc, it should work.
of course you'll have to change the javascript load:
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="effects.js"></script>
<script type="text/javascript" src="accordion.js"></script>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
Next Message by Date:
click to view message preview
RE: Accordion
What happens in your version? In mine it looks like crap. When I click on a
heading it scrolls up and disappears. I mean the whole section is
gone....vanished, so the top header that’s there is now the second one.
Click that one and it scrolls up and disappears just like the first.
Dave
-----Original Message-----
From: mcway_web_design@xxxxxxx [mailto:mcway_web_design@xxxxxxx]
Sent: March-08-09 7:14 PM
To: CakePHP
Subject: Re: Accordion
I am having this exact same problem...i have cut and pasted directly from
the site, but can't even get the example accordion to work!
Here is a link to my code: http://bin.cakephp.org/view/346411466
Any insight is much appreciated!
On Mar 6, 7:39 pm, "Dave Maharaj :: WidePixels.com"
<d...@xxxxxxxxxxxxxx> wrote:
> Still no luck. I need the scriptaculous.js in there for other
> elements on the page.
>
> In the view file:
> <?php
> echo $javascript->link(array('prototype', 'scriptaculous',
> 'effects', 'accordion')); ?>
>
> <div id="vertical_container" >
>
> <h2 class="accordion_toggle">Title Bar</h2>
> <div class="accordion_content">
> <p>Well i listened to all you guys out there in my forum and my
> blog and now all those wishes have been granted!</p>
> <p>
> <ul style="margin: 0 0 0 50px;">
> <li>Open/Close functionality added (Click on an
> activeaccordion).</li>
> <li>Nested Vertical Accordions</li>
> <li>Accordions will dynamically resize on content added REAL
> TIME!</li>
> <li>...lots of bug fixes!</li>
> </ul>
> </p>
> </div>
>
> <h2 class="accordion_toggle">Title Bar</h2>
> <div class="accordion_content">
> <p>Well i listened to all you guys out there in my forum and my
> blog and now all those wishes have been granted!</p>
> <p>
> <ul style="margin: 0 0 0 50px;">
> <li>Open/Close functionality added (Click on an
> activeaccordion).</li>
> <li>Nested Vertical Accordions</li>
> <li>Accordions will dynamically resize on content added REAL
> TIME!</li>
> <li>...lots of bug fixes!</li>
> </ul>
> </p>
> </div>
>
> <h2 class="accordion_toggle">Title Bar</h2>
> <div class="accordion_content">
>
> <p>Well i listened to all you guys out there in my forum and my
> blog and now all those wishes have been granted!</p>
> <p>
> <ul style="margin: 0 0 0 50px;">
> <li>Open/Close functionality added (Click on an
> activeaccordion).</li>
> <li>Nested Vertical Accordions</li>
> <li>Accordions will dynamically resize on content added REAL
> TIME!</li>
> <li>...lots of bug fixes!</li>
> </ul>
> </p>
> </div>
> </div>
>
> <script type="text/javascript">
>
> Event.observe(window, 'load',
> loadAccordions, false);
>
> function loadAccordions() {
>
> var bottomAccordion =
> newaccordion('vertical_container');
> }
>
> </script>
>
> -----Original Message-----
> From: Stu [mailto:greenmushroo...@xxxxxxxxx]
> Sent: March-06-09 4:58 PM
> To: CakePHP
> Subject: Re:Accordion
>
> Not sure if you need the scriptaculous script for anything else, but
> you don't need it for this. Also you're missing effects.js which is
> specified on the website.
>
> You might wanna take out some of that code too, you don't need all of
> that, for instance:
>
> > var topAccordion = new
> >accordion('horizontal_container', {
> > classNames : {
> > toggle :
> > 'horizontal_accordion_toggle',
> > toggleActive :
> > 'horizontal_accordion_toggle_active',
> > content :
> > 'horizontal_accordion_content'
> > },
> > defaultSize : {
> > width : 525
> > },
> > direction : 'horizontal'
> > });
>
> > var nestedVerticalAccordion = new
> >accordion('vertical_nested_container', {
> > classNames : {
> > toggle :
> > 'vertical_accordion_toggle',
> > toggleActive :
> > 'vertical_accordion_toggle_active',
> > content :
> > 'vertical_accordion_content'
> > }
> > });
>
> > // Open second one
>
> > topAccordion.activate($$('#horizontal_container
> > .horizontal_accordion_toggle')[2]);
> > }
>
> All of that is if you wanted to use the nestedaccordionor the
> horizontal accordions.
>
> try that and post whatever happens next.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
Previous Message by Thread:
click to view message preview
Re: Redirect after an edit operation in a paginated view
On Mar 11, 11:52 am, Danny Lieberman <onlyj...@xxxxxxxxx> wrote:
> This doesn't work
> I have an edit method and a fu method - both do database saves. BUT
> the cake automagic stuff always sends the user back to the edit method
> after fu save operation - this looks like a bug
Assumptions + monologues are ace, you might want to discuss things on
#cakephp rather than use the group for brain dumps ;).
The default form action (which obviously, you can change - check the
book) has always been add/edit depending on whether you have no model
data loaded or not. Which given your description means your controller/
fu form is posting to controller/edit.
AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
Next Message by Thread:
click to view message preview
Re: Redirect after an edit operation in a paginated view
Doesn't work - I have diagnosed the problem
There are two methods in the controller that perform an update - edit
and fu (followup) the fu controller has its own fu.ctp view and edit
has edit.ctp BUT whenever the user submits the fu.ctp form - the
control is passed to the EDIT method not to the originally calling
method
This looks like a bug to me
Danny
On Mar 9, 4:09 pm, AD7six <andydawso...@xxxxxxxxx> wrote:
> On Mar 9, 11:26 am, Danny Lieberman <onlyj...@xxxxxxxxx> wrote:
>
>
>
> > This would seem to be a trivial task. I have a list of paginated
> > rows. I want to be able to click on an edit operation on a
> > particular page > 1 and return to the same page. I save the referer
> > on entry to the function and redirect to the saved referer after the
> > database save operation - but the controller always returns to the
> > controller index method no matter what the user chooses.
>
> > I'm running in production mode - perhaps this is related to debug=0?
>
> > Here is the code:
> > function fu($id = null) {
> > $refer = Controller::referer(); // save the calling
> > page
> > if (!$id && empty($this->data)) {
> > $this->Session->setFlash(__('Invalid Contact',
> > true));
> > $this->redirect(array('action'=>'index'));
> > }
> > echo$refer;
> > if (!empty($this->data)) {
> > if ($this->Contact->save($this->data)) {
> > $this->Session->setFlash(__('The
> > Contact has been saved', true));
> > // $this->redirect(array
> > ('action'=>'index'));
> > $this->redirect($refer); // redirect
> > back to the calling page after save
> > } else {
> > $this->Session->setFlash(__('The
> > Contact could not be saved. Please, try again.', true));
> > }
> > }
> > if (empty($this->data)) {
> > $this->data = $this->Contact->read(null, $id);
> > }
> > $this->set('contact', $this->Contact->read(null,
> > $id));
>
> > Looks like something really stupid is breaking this but I cant figure
> > out what
>
> > Danny
>
> Try this logic:
>
> In the controller:
>
> if (!$this->data) {
> $this->set('referer', $this->referer($default));} else {
>
> if ($this->Model->save()) {
> $this->redirect ($this->data['_App']['referer']);
>
> }
> }
>
> in the view:
> ...
> echo $form->input('_App.referer', array('value' => $referer, 'type' =>
> 'hidden'));
> ...
>
> Personally, I always add a referer to all forms to use for exactly the
> purpose you highlight.
>
> hth,
>
> AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|