[jifty-devel] Example of a form that sends its rusult to the own
region?
Andreas J. Koenig
andreas.koenig.7os6VVqR at franz.ak.mind.de
Mon Jun 18 18:41:41 EDT 2007
>>>>> On Mon, 18 Jun 2007 11:51:39 -0400, Jesse Vincent <jesse at bestpractical.com> said:
> On Jun 17, 2007, at 9:01 AM, Andreas J. Koenig wrote:
>> Maybe I'm blind but I'm just overwhelmed by the rich set of
>> documentation and at the moment I cannot figure out how to write a
>> simple form with a simple submit button that sends the content of a
>> simple text field only to its own region.
>>
> So, you have a region defined ok, right?
Yes, I have now 5 regions.
In 4 of them I got everything working as I wanted with the help of
"Jifty->web->link()". It was a lot of fun by the way and the regions
talk very nicely to each other and update themselves. But now I want a
text field, a simple text field.
> And you _can_ get at Jifty-
> handler-> cgi to get your argument (though we'd normally be running
> CGI params through a Jifty::Action)?
I get an object when I run Jifty->handler->cgi, blessed into CGI, but
it doesn't help me, the param method returns nothing interesting.
> I _think_ that the automatic region submit stuff will only submit
> action parameters, not all form fields (though Firebug will tell you
> for sure)
I think you describe my problem very well.
> I think Sterling explained the as_button/as_link stuff, so you can
> render the Jifty->web->link as you want.
Yes, thanks, Sterling, the onclick and the as_button arguments were
helpful, but I'm still missing the parameter from the form field.
> If you explain what you're doing i na bit more detail, I can help fill
> in missing pieces. (Though I'm offline from 20 June to 4 July).
I cut it down to this simple example which at the moment does not do
anything useful but should make my intentions clear. A single form
field and a button. What I'm missing now is a way to read the value
that the user has typed in. I append my unsuccessful code and the
output from Data::Dumper below.
Thanks for your help,
--
andreas
<%args>
</%args>
<%init>
my $action = Jifty->web->new_action(
class => 'SearchDistro',
arguments => {'searchterm' => undef},
);
my $cgi = Jifty->handler->cgi();
my $st1 = $cgi->param('searchterm');
my $st2 = $action->get('searchterm');
require Data::Dumper;
warn Data::Dumper->new([CGI => $cgi, A => $action, ST1 => $st1, ST2 => $st2],[qw()])->Indent(1)->Useqq(1)->Dump;
</%init>
<div align="left">
<% Jifty->web->form->start() %>
<% $action->form_field('searchterm') %>
<% $action->button( label => 'Search',
onclick => {
refresh => "querydemo",
}
) %>
<% Jifty->web->form->end() %>
</div>
WARN - $VAR1 = "CGI";
$VAR2 = bless( {
".parameters" => [
"POSTDATA"
],
"use_tempfile" => 1,
".charset" => "ISO-8859-1",
"POSTDATA" => [
"{\"path\":\"/__jifty/webservices/xml\",\"actions\":{},\"fragments\":{\"querydemo\":{\"name\":\"querydemo\",\"path\":\"/fragments/querydemo\",\"args\":{},\"parent\":null}},\"variables\":{\"region-querydemo\":\"/fragments/querydemo\",\"region-pocpocsessions\":\"/fragments/page_of_sessions\",\"region-pocpocsessions.s_page\":\"2\",\"region-pocpocsessions.s_selected_row\":\"0\"},\"continuation\":{}}"
],
".fieldnames" => {},
"escape" => 1
}, 'CGI' );
$VAR3 = "A";
$VAR4 = bless( {
"sticky_on_failure" => 1,
"sticky_on_success" => 0,
"values_from_request" => {
"searchterm" => 0
},
"moniker" => "auto-b1dadc3d60f9d4caf64464586dfa305d-1",
"_current_user" => bless( {
"is_superuser" => 1
}, 'Pocpoc::CurrentUser' ),
"record" => bless( {
"_current_user" => $VAR4->{"_current_user"},
"input_filters" => [
"Jifty::DBI::Filter::Truncate"
]
}, 'Pocpoc::Model::Distro' ),
"order" => undef,
"argument_values" => {
"searchterm" => undef
},
"result" => bless( {
"_content" => {},
"failure" => 0,
"action_class" => "Pocpoc::Action::SearchDistro"
}, 'Jifty::Result' )
}, 'Pocpoc::Action::SearchDistro' );
$VAR5 = "ST1";
$VAR6 = undef;
$VAR7 = "ST2";
$VAR8 = undef;
More information about the jifty-devel
mailing list