diff --git a/Mango.tmproj b/Mango.tmproj
index da6dcb0..f797fcb 100644
--- a/Mango.tmproj
+++ b/Mango.tmproj
@@ -3,7 +3,7 @@
currentDocument
- share/templates/tt/html/products/list
+ lib/Mango/Form.pm
documents
@@ -18,7 +18,7 @@
fileHierarchyDrawerWidth
- 290
+ 288
metaData
lib/Mango/Catalyst/Controller/Checkout.pm
@@ -35,42 +35,42 @@
firstVisibleLine
5
- share/templates/tt/html/cart/view
+ lib/Mango/Form.pm
caret
column
- 77
+ 0
line
- 27
+ 0
firstVisibleColumn
0
firstVisibleLine
- 0
+ 20
- share/templates/tt/html/login/index
+ t/catalyst/controller_form.t
caret
column
- 64
+ 21
line
- 0
+ 53
firstVisibleColumn
0
firstVisibleLine
- 0
+ 36
- share/templates/tt/html/products/list
+ t/form.t
caret
column
- 70
+ 0
line
- 1
+ 24
firstVisibleColumn
0
@@ -108,13 +108,13 @@
openDocuments
- share/templates/tt/html/login/index
- share/templates/tt/html/cart/view
- share/templates/tt/html/products/list
+ lib/Mango/Form.pm
+ t/catalyst/controller_form.t
+ t/form.t
showFileHierarchyDrawer
windowFrame
- {{300, 27}, {1620, 1151}}
+ {{1082, 54}, {838, 1124}}
diff --git a/lib/Mango/Form.pm b/lib/Mango/Form.pm
index e536445..db02f50 100644
--- a/lib/Mango/Form.pm
+++ b/lib/Mango/Form.pm
@@ -46,7 +46,7 @@ sub new {
sub action {
my ( $self, $action ) = @_;
-warn "SETTING ACTION: $action";
+
if ($action) {
$self->_form->action("$action");
}
@@ -63,6 +63,7 @@ sub clone {
$self->localizer(undef);
my $form = Clone::clone($self);
+ $form->_form($self->_form->clone);
$self->params($params);
$self->localizer($localizer);
@@ -81,31 +82,24 @@ sub render {
my %args = @_;
my $form = $self->_form;
- ## CGI::FB Hates URI Objects
- if ( exists $args{'action'} ) {
- $args{'action'} = $args{'action'} . '';
+ foreach my $arg (keys %args) {
+ next if $arg =~ /values/i;
+ $self->$arg($args{$arg});
}
- #foreach my $field ( $form->fields ) {
- # $field->label(
- # $self->localizer->(
- # $self->labels->{ $field->name },
- # $field->name
- # )
- # );
- #}
- #$form->submit( $self->localizer->( $self->labels->{'submit'} ) );
-
- ## keeps CGI::FB from bitching about empty basename
- local $ENV{'SCRIPT_NAME'} ||= '';
+ my $fields = $form->get_fields;
+ if (my $values = $args{'values'}) {
+ for (my $i = 0; $i < scalar @{$values};$i++) {
+ next unless $fields->[$i];
- my $render = $form->render(%args);
+ $fields->[$i]->value($values->[$i]);
+ }
+ }
- if (lc $self->{'mode'} eq 'xhtmlstrict') {
- $render =~ s/(\s+name=\".*\")//i;
- };
+ $form->method(lc $form->method);
- return $render;
+ $form->process;
+ return $form->render;
}
sub values {
@@ -132,7 +126,7 @@ sub parse {
my $fields = delete $config->{'fields'};
my $indicator = '_submitted_' . ($config->{'id'} || $config->{'name'} || 'noidorname');
- push @{$fields}, { $indicator => {type => 'Submit'}};
+ push @{$fields}, { $indicator => {type => 'Hidden', value => 1}};
$config->{'indicator'} = $indicator;
delete $config->{'sticky'};
@@ -170,7 +164,7 @@ sub _parse_fields {
$type =~ s/checkbox/Checkbox/i;
if ($type eq 'Checkbox' && exists $field->{'multiple'} && $field->{'multiple'}) {
- $type => 'Checkboxgroup';
+ $type = 'Checkboxgroup';
};
## migrate disabled
diff --git a/share/templates/tt/html/cart/view b/share/templates/tt/html/cart/view
index ac9aeda..b3d54d3 100644
--- a/share/templates/tt/html/cart/view
+++ b/share/templates/tt/html/cart/view
@@ -31,8 +31,7 @@
[% SET form = c.forms('cart_items_delete') %]
[% CALL form.id(form.id _ '_' _ item.id) %]
[% form.render(
- 'action', c.uri_for_resource('mango/cart/items', 'delete', [item.id]) _ '/',
- 'values', [item.id, item.quantity]
+ 'action', c.uri_for_resource('mango/cart/items', 'delete', [item.id]) _ '/'
) %]
diff --git a/share/templates/tt/html/errors/401 b/share/templates/tt/html/errors/401
index 1308571..a0e95dc 100644
--- a/share/templates/tt/html/errors/401
+++ b/share/templates/tt/html/errors/401
@@ -1,4 +1,4 @@
-[% page.title = c.localize('UNAUTHORIZED') %]
+[% page.title = c.localize('UNAUTHORIZED'), page.id = 'error-401' %]
[% c.localize('UNAUTHORIZED_MESSAGE') %]
diff --git a/share/templates/tt/html/errors/404 b/share/templates/tt/html/errors/404
index f1244b0..0be203b 100644
--- a/share/templates/tt/html/errors/404
+++ b/share/templates/tt/html/errors/404
@@ -1,4 +1,4 @@
-[% page.title = c.localize('RESOURCE_NOT_FOUND') %]
+[% page.title = c.localize('RESOURCE_NOT_FOUND'), page.id = 'error-404' %]
[% c.localize('RESOURCE_NOT_FOUND_MESSAGE') %]
diff --git a/t/lib/Mango/Test/Class.pm b/t/lib/Mango/Test/Class.pm
index 5f5b22f..3c92d85 100644
--- a/t/lib/Mango/Test/Class.pm
+++ b/t/lib/Mango/Test/Class.pm
@@ -64,6 +64,7 @@ sub validate_markup {
if ( $v->is_valid ) {
pass('content is valid');
} else {
+ my ($package, $filename, $line) = caller;
my $message;
foreach my $error ( @{$v->errors} ) {
$message .= sprintf("line: %s, column: %s error: %s\n",
@@ -73,7 +74,7 @@ sub validate_markup {
$message .= ' ' . $lines[$error->line - 1] . "\n";
}
- fail 'content is not valid' or diag $message;;
+ fail "content is not valid at $package line $line" or diag $message;;
}
} else {
fail('Failed to validate the content: ' . $v->validator_error);