I have a problem where a method defines a variable but it isn't passing to the next component.  I'm not sure what to do at this point, I have spent a couple of days on this and dont know what else to try.  Obviously, there is something I have missed or otherwise do not understand clearly.  Hoping someone will be kind enough to help.  I am not new to coding but have only been working with mason a couple of months in my spare time.
 
At the top of every page of my test site, there is a simple username/password login form, and submit button.  When someone submits the form, autohandler loads a session.mpl module which then loads index.html.
 
I am trying to define a $var in session and pass it to index.  I am showing that it is being defined, however, index.html never gets it.  Totally puzzling.
 

init section of autohandler contains:
 
my $reqargs = $m->request_args;
my $mode = $reqargs->{mode};
if($mode eq 'login-submit'){
        $page_content = $m->comp('session.mpl:login', %ARGS);
        }
else{
        $page_content = $m->scomp($m->fetch_next, %ARGS);
        }
 
OK, when someone submits a username password with login form, mode == 'login-submit'.
 
* session.mpl is successfully receiving %ARGS with username and password.
* session.mpl successfully defines $toptext but does not seem to pass it to index.html.
 
.. from session.mpl:
 
if($password eq undef){ $toptext = 'Invalid Password'; }
 
I also have $toptext => undef in my %args section of the session:login method.
 
so finally, session.mpl loads the next component (index.html):
 
$page_content = $m->scomp($m->fetch_next, %ARGS);
return $page_content;
 
%ARGS should contain $toptext => 'Invalid Password' at this point.
 
$page_content is then displayed by autohandler.
 
if I return $toptext, I am seeing it is being defined as expected.  Why isnt index.html grabbing the ARG??
 
The only problem is that I am defining $toptext but it never displays in index.html.  I dont understand.  Everything says you can define a $var in a module and pass it on but I'm not sure why it isnt working for me... let me know how I can help you help me.
The only thing left to say is ARGH! in a frustrated pirate sorta voice. :)
 
Much thanks for any assistance,
 
Kris
 

Reply via email to