[Jifty-commit] r527 - in jifty/trunk: lib/Jifty/Web/Form t/Mapper/t
t/Mapper/web/templates
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Jan 24 21:25:23 EST 2006
Author: alexmv
Date: Tue Jan 24 21:25:23 2006
New Revision: 527
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Web/Form/Field.pm
jifty/trunk/t/Mapper/t/02-api.t
jifty/trunk/t/Mapper/web/templates/index.html
Log:
r8779 at zoq-fot-pik: chmrr | 2006-01-24 21:24:47 -0500
* Support mapping on both sticky_value and default_value
Modified: jifty/trunk/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field.pm Tue Jan 24 21:25:23 2006
@@ -86,12 +86,13 @@
# If they key and/or value imply that this argument is going to be
# a mapped argument, then do the mapping and mark the field as hidden.
- my ($key, $value) = Jifty::Request::Mapper->query_parameters($self->input_name, $self->default_value);
+ my ($key, $value) = Jifty::Request::Mapper->query_parameters($self->input_name, $self->current_value);
if ($key ne $self->input_name) {
require Jifty::Web::Form::Field::Hidden;
bless $self, "Jifty::Web::Form::Field::Hidden";
$self->input_name($key);
$self->default_value($value);
+ $self->sticky_value(undef);
}
# now that the form field has been instantiated, register the action with the form.
Modified: jifty/trunk/t/Mapper/t/02-api.t
==============================================================================
--- jifty/trunk/t/Mapper/t/02-api.t (original)
+++ jifty/trunk/t/Mapper/t/02-api.t Tue Jan 24 21:25:23 2006
@@ -11,7 +11,7 @@
BEGIN {chdir "t/Mapper"}
use lib '../../lib';
-use Jifty::Test tests => 8;
+use Jifty::Test tests => 11;
use_ok('Jifty::Test::WWW::Mechanize');
@@ -29,12 +29,19 @@
$mech->get("$URL/index.html?J:A-grail=GetGrail");
$mech->content_like(qr/got the grail/, "Running the action produces the expected result");
-# Feeding the first action into the second should cause both to run
+# Feeding the first action into the second should cause both to run;
+# first, test via setting arguments during action creation (which sets
+# sticky values)
$mech->form(2);
ok($mech->click_button(value => "Do both"));
$mech->content_like(qr/got the grail/i, "Got the grail");
$mech->content_like(qr/crossed the bridge/i, "And crossed the bridge");
+# And then, the same, but via deault_values on the form field
+$mech->form(3);
+ok($mech->click_button(value => "Do both"));
+$mech->content_like(qr/got the grail/i, "Got the grail");
+$mech->content_like(qr/crossed the bridge/i, "And crossed the bridge");
1;
Modified: jifty/trunk/t/Mapper/web/templates/index.html
==============================================================================
--- jifty/trunk/t/Mapper/web/templates/index.html (original)
+++ jifty/trunk/t/Mapper/web/templates/index.html Tue Jan 24 21:25:23 2006
@@ -8,9 +8,20 @@
<% Jifty->web->form->start %>
-% my $grail = Jifty->web->form->add_action( class => 'GetGrail', order => 1 );
-% my $bridge = Jifty->web->new_action( class => 'CrossBridge', order => 2 );
-<% $bridge->form_field( 'quest', default_value => { result_of => $grail, name => 'castle' } ) %>
-<% $bridge->form_field( 'colour', default_value => 'Green' ) %>
+% my $grail_1 = Jifty->web->form->add_action( class => 'GetGrail', order => 1 );
+% my $bridge_1 = Jifty->web->new_action( class => 'CrossBridge', order => 2 );
+<% $bridge_1->form_field( 'quest', default_value => { result_of => $grail_1, name => 'castle' } ) %>
+<% $bridge_1->form_field( 'colour', default_value => 'Green' ) %>
+<% Jifty->web->form->submit( label => 'Do both') %>
+<% Jifty->web->form->end %>
+
+
+<% Jifty->web->form->start %>
+% my $grail_2 = Jifty->web->form->add_action( class => 'GetGrail', order => 1 );
+% my $bridge_2 = Jifty->web->new_action( class => 'CrossBridge',
+% order => 2,
+% arguments => { quest => { result_of => $grail_2, name => 'castle' } } );
+<% $bridge_2->form_field( 'quest' ) %>
+<% $bridge_2->form_field( 'colour', default_value => 'Green' ) %>
<% Jifty->web->form->submit( label => 'Do both') %>
<% Jifty->web->form->end %>
More information about the Jifty-commit
mailing list