Changeset 33779 for lang/perl/MENTA
- Timestamp:
- 06/04/09 13:11:42 (4 years ago)
- Location:
- lang/perl/MENTA/trunk/extlib/HTML
- Files:
-
- 5 modified
-
AutoForm.pm (modified) (7 diffs)
-
AutoForm/Field.pm (modified) (1 diff)
-
AutoForm/Field/InputCheckable.pm (modified) (1 diff)
-
AutoForm/Field/Option.pm (modified) (2 diffs)
-
AutoForm/Field/Select.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/MENTA/trunk/extlib/HTML/AutoForm.pm
r25687 r33779 27 27 our $CLASS_PREFIX; 28 28 29 sub DEBUG () { $ENV{HTML_AUTOFORM_DEBUG} && 1 } 30 29 31 BEGIN { 30 32 $VERSION = '0.01'; … … 74 76 my $opts = $fields->[$i + 1]; 75 77 die 'field type is missing or invalid' 76 unless $opts->{type} =~ /^(text|hidden|password|radio|select|checkbox|textarea )$/;78 unless $opts->{type} =~ /^(text|hidden|password|radio|select|checkbox|textarea|file)$/; 77 79 my $field_klass = 'HTML::AutoForm::Field::' . ucfirst $opts->{type}; 78 80 push @{$self->{fields}}, $field_klass->new( … … 106 108 '"', 107 109 ($self->secure ? ' method="POST"' : ''), 110 ((grep {$_->type eq 'file'} @{$self->{fields}}) ? 111 ' enctype="multipart/form-data"' : ''), 108 112 '>', 109 113 '<table class="', … … 124 128 ); 125 129 if ($do_validate) { 126 print STDERR "validating: ", $field->name, "\n";127 130 if (my $err = $field->validate($query)) { 128 131 push( … … 176 179 for my $f (@{$self->{fields}}) { 177 180 if (my $error = $f->validate($query)) { 181 print STDERR ( 182 'validation error:', $f->name, ':', $error->message, "\n", 183 ) if DEBUG; 178 184 return; 179 185 } elsif (my $h = $f->custom) { 180 186 if (my $error = $h->($f, $query)) { 187 print STDERR ( 188 'custom validation error:', $f->name, ':', $error->message, 189 "\n", 190 ) if DEBUG; 181 191 return; 182 192 } … … 188 198 if ($check_csrf_callback->($csrf_value)) { 189 199 $ok = 1; 200 } else { 201 print STDERR 'csrf validation error:', "\n" 202 if DEBUG; 190 203 } 204 } else { 205 print STDERR 'no csrf key', "\n" 206 if DEBUG; 191 207 } 192 208 return 193 209 unless $ok; 194 210 } 211 print STDERR "no errors found in validation\n" 212 if DEBUG; 195 213 1; 196 214 } … … 202 220 ($_ => $base->{$_}) 203 221 } grep { 204 ! exists $omit->{$_} && ! /^(allow_multiple|label|required )$/222 ! exists $omit->{$_} && ! /^(allow_multiple|label|required|xhtml_compat)$/ 205 223 } keys %$base), 206 224 %$extra, 207 225 ); 226 my $is_xhtml = $base->{xhtml_compat}; 208 227 my $html = join( 209 228 '', 210 229 '<' . $tag, 211 230 (map { 212 ' ' . $_ . '="' . _escape_html($attr{$_}) . '"' 231 $is_xhtml || $_ ne $attr{$_} || 232 ! /^(?:(?:check|disable|select)ed|readonly)$/ 233 ? ' ' . $_ . '="' . _escape_html($attr{$_}) . '"' 234 : ' ' . $_; 213 235 } sort grep { 214 236 defined $attr{$_} 215 237 } keys %attr), 216 defined $append ? ('>', $append, '</', $tag, '>') : ' />',238 defined $append ? ('>', $append, '</', $tag, '>') : ($is_xhtml ? ' />' : '>'), 217 239 ); 218 240 $html; -
lang/perl/MENTA/trunk/extlib/HTML/AutoForm/Field.pm
r25497 r33779 15 15 custom => undef, 16 16 allow_multiple => undef, 17 xhtml_compat => 1, 17 18 ); 18 19 Class::Accessor::Lite->mk_accessors(keys %Defaults); -
lang/perl/MENTA/trunk/extlib/HTML/AutoForm/Field/InputCheckable.pm
r25497 r33779 39 39 ? grep { $_ eq $self->{value} } @$values 40 40 : $self->{checked}) 41 ? (checked => 1) : (),41 ? (checked => 'checked') : (), 42 42 }, 43 43 { -
lang/perl/MENTA/trunk/extlib/HTML/AutoForm/Field/Option.pm
r25497 r33779 6 6 7 7 BEGIN { 8 Class::Accessor::Lite->mk_accessors(qw(value label selected ));8 Class::Accessor::Lite->mk_accessors(qw(value label selected xhtml_compat)); 9 9 }; 10 10 … … 23 23 $self, 24 24 ($values ? grep { $_ eq $self->{value} } @$values : $self->{selected}) 25 ? { selected => 1} : {},25 ? { selected => 'selected' } : {}, 26 26 { selected => 1 }, 27 27 $self->{label}, -
lang/perl/MENTA/trunk/extlib/HTML/AutoForm/Field/Select.pm
r25497 r33779 30 30 %$attributes, 31 31 value => $value, 32 xhtml_compat => $self->xhtml_compat, 32 33 ); 33 34 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)