MAR Model

[Clarification]

Yes it works but in the same way it did before I tried to pass
variables or flash messages. It’s still a plain vanilla redirect. I’m
back to where I started is what I should have said.

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Just to follow-up Walter, I got the flash “success” message to appear
on the form page (just as the flash “error” message does). I still
haven’t been able to pass the name variable to a separate (redirect)
page as I was originally trying to do but c’est la vie. I’ll deal with
that some other time.

Here’s the updated (working) controller with the “success” case
disabled, if you’re interested. <http://dl.dropbox.com/u/550492/controller.php

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This should just work if you change the $self link to a link to
success in the manage_result call. $link = '/folder/mar/success/' . $mar->id; and use $link in place of $self where you have it currently.

The session flash will be set by manage_result to the value of
$message, The next request for that session (inside of success) will
pick that up and display it as long as you have a line of code to
echo $_flash in your views/success.php page
.

Walter

On Mar 27, 2011, at 11:29 AM, Todd wrote:

Just to follow-up Walter, I got the flash “success” message to
appear on the form page (just as the flash “error” message does). I
still haven’t been able to pass the name variable to a separate
(redirect) page as I was originally trying to do but c’est la vie.
I’ll deal with that some other time.

Here’s the updated (working) controller with the “success” case
disabled, if you’re interested. <http://dl.dropbox.com/u/550492/controller.php

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This should just work if you change the $self link to a link to
success in the manage_result call. $link = '/folder/mar/success/' . $mar->id; and use $link in place of $self where you have it
currently.

Curious. I’m not sure why but the “success” case goes missing.
Meaning, instead of a redirect the session flash loads in the same
(form) page.

<?php
switch ($verb) {
case 'index':
	default:
		# code...
		$mar = ActiveRecord::Create('mar');
		if(isset($_SESSION['flash'])){
			$mar->_flash = $_SESSION['flash'];
			unset($_SESSION['flash']);
		}
		if(isset($_POST['submit'])){
			$mar->populate(clean($_POST));
			$mar->save();
			$message = 'Message sent, ' . $mar->h('name') . '. Bye !';
			$mar->manage_result('_flash','flash',$message,'',$link = '/mar/ 
success/' . $mar->id);
		}
		$page_title = 'Connect';
		$out .= render_partial('form',$mar);
		include(APP_ROOT . '/views/index.php');
		break;

case 'success':
	# code...
	if($mar = ActiveRecord::FindById('mar',$id)){
		$page_title = 'Connection Complete';
		$message = '' . $mar->h('name') . '';
		if(isset($_SESSION['flash'])){
			$mar->_flash = $_SESSION['flash'];
			unset($_SESSION['flash']);
		}
		$out .= render_partial('success',$mar);
		include(APP_ROOT . '/views/success.php');
	}
	break;
}
?>

dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Try losing the leading slash in the link. so it’s mar/success …

Walter

On Mar 27, 2011, at 1:03 PM, Todd wrote:

This should just work if you change the $self link to a link to
success in the manage_result call. $link = '/folder/mar/ success/' . $mar->id; and use $link in place of $self where you
have it currently.

Curious. I’m not sure why but the “success” case goes missing.
Meaning, instead of a redirect the session flash loads in the same
(form) page.

<?php
switch ($verb) {
case 'index':
	default:
		# code...
		$mar = ActiveRecord::Create('mar');
		if(isset($_SESSION['flash'])){
			$mar->_flash = $_SESSION['flash'];
			unset($_SESSION['flash']);
		}
		if(isset($_POST['submit'])){
			$mar->populate(clean($_POST));
			$mar->save();
			$message = 'Message sent, ' . $mar->h('name') . '. Bye !';
			$mar->manage_result('_flash','flash',$message,'',$link = '/mar/ 
success/' . $mar->id);
		}
		$page_title = 'Connect';
		$out .= render_partial('form',$mar);
		include(APP_ROOT . '/views/index.php');
		break;

case 'success':
	# code...
	if($mar = ActiveRecord::FindById('mar',$id)){
		$page_title = 'Connection Complete';
		$message = '' . $mar->h('name') . '';
		if(isset($_SESSION['flash'])){
			$mar->_flash = $_SESSION['flash'];
			unset($_SESSION['flash']);
		}
		$out .= render_partial('success',$mar);
		include(APP_ROOT . '/views/success.php');
	}
	break;
}
?>

dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Try losing the leading slash in the link. so it’s mar/success …

I forgot to mention that I tried that earlier. The session flash still
loads in the same (form) page.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

It could only do that if there are errors in the model after you save
it. manage_result has a very simple path:

  1. Are there errors in the model after Save?
    1. Yes → Show the form page again, with the errors in the local flash.
    2. No → Redirect to the success url with the message in the session
      flash.

Walter

On Mar 27, 2011, at 3:47 PM, Todd wrote:

Try losing the leading slash in the link. so it’s mar/success …

I forgot to mention that I tried that earlier. The session flash
still loads in the same (form) page.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

It could only do that if there are errors in the model after you
save it. manage_result has a very simple path:

  1. Are there errors in the model after Save?
  2. Yes → Show the form page again, with the errors in the local
    flash.
  3. No → Redirect to the success url with the message in the
    session flash.

I know, it’s odd, there aren’t a lot of places for manage_result to go
off the tracks. There are no errors. The “success” flash loads in the
same page and the email gets sent and the data is passed to the db. It
must be something very obvious I’m overlooking.

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options