Changeset 28 in text-formbuilder for trunk/lib/Text/FormBuilder.pm
- Timestamp:
- 11/17/04 09:07:38 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Text/FormBuilder.pm
r26 r28 6 6 use vars qw($VERSION); 7 7 8 $VERSION = '0.06_0 1';8 $VERSION = '0.06_02'; 9 9 10 10 use Carp; … … 12 12 use CGI::FormBuilder; 13 13 14 # the default options passed to CGI::FormBuilder->new14 # the static default options passed to CGI::FormBuilder->new 15 15 my %DEFAULT_OPTIONS = ( 16 16 method => 'GET', … … 77 77 78 78 # substitute in custom pattern definitions for field validation 79 if (my %patterns = %{ $self->{form_spec}{patterns} }) {79 if (my %patterns = %{ $self->{form_spec}{patterns} || {} }) { 80 80 foreach (@{ $self->{form_spec}{fields} }) { 81 81 if ($$_{validate} and exists $patterns{$$_{validate}}) { … … 85 85 } 86 86 87 ## # so we don't get all fields required88 ## foreach (@{ $self->{form_spec}{fields} }) {89 ## delete $$_{validate} unless $$_{validate};90 ## }91 92 87 # expand groups 93 my %groups = %{ $self->{form_spec}{groups} };94 foreach (grep { $$_[0] eq 'group' } @{ $self->{form_spec}{lines} }) {88 my %groups = %{ $self->{form_spec}{groups} || {} }; 89 foreach (grep { $$_[0] eq 'group' } @{ $self->{form_spec}{lines} || [] }) { 95 90 $$_[1]{group} =~ s/^\%//; # strip leading % from group var name 96 91 … … 107 102 108 103 $self->{form_spec}{fields} = []; 109 for my $line (@{ $self->{form_spec}{lines} }) {104 for my $line (@{ $self->{form_spec}{lines} || [] }) { 110 105 if ($$line[0] eq 'group') { 111 106 push @{ $self->{form_spec}{fields} }, $_ foreach @{ $$line[1]{group} }; … … 117 112 118 113 # substitute in list names 119 my %lists = %{ $self->{form_spec}{lists} };114 my %lists = %{ $self->{form_spec}{lists} || {} }; 120 115 foreach (@{ $self->{form_spec}{fields} }) { 121 116 next unless $$_{list}; … … 169 164 data => { 170 165 lines => $self->{form_spec}{lines}, 171 headings => $self->{form_spec}{headings},172 166 author => $self->{form_spec}{author}, 173 167 description => $self->{form_spec}{description}, … … 215 209 # don't dump $VARn names 216 210 $Data::Dumper::Terse = 1; 217 218 my $title = $self->{form_spec}{title} || '';219 my $author = $self->{form_spec}{author} || '';220 my $description = $self->{form_spec}{description} || '';221 222 my $headings = Data::Dumper->Dump([$self->{form_spec}{headings}],['headings']);223 my $lines = Data::Dumper->Dump([$self->{form_spec}{lines}],['lines']);224 my $fields = Data::Dumper->Dump([ [ map { $$_{name} } @{ $self->{form_spec}{fields} } ] ],['fields']);225 211 226 212 my %options = ( … … 238 224 data => { 239 225 lines => $self->{form_spec}{lines}, 240 headings => $self->{form_spec}{headings},241 226 author => $self->{form_spec}{author}, 242 227 description => $self->{form_spec}{description}, … … 338 323 $OUT .= (grep { $$_{invalid} } @group_fields) ? qq[ <tr class="invalid">\n] : qq[ <tr>\n]; 339 324 340 #TODO: validated but not required fields341 # in a form spec: //EMAIL?342 343 325 $OUT .= ' <th class="label">'; 344 326 $OUT .= (grep { $$_{required} } @group_fields) ? qq[<strong class="required">$$line[1]{label}:</strong>] : "$$line[1]{label}:"; … … 740 722 =head1 TODO 741 723 742 DWIM for single valued checkboxes (e.g. C<moreinfo|Send me more info:checkbox>)743 744 724 Use the custom message file format for messages in the built in template 745 725 746 726 C<!section> directive to split up the table into multiple tables, each 747 727 with their own id and (optional) heading 728 729 Use HTML::Template instead of Text::Template for the built in template 730 (since CGI::FormBuilder users may be more likely to already have HTML::Template) 748 731 749 732 Better examples in the docs (maybe a standalone or two as well)
Note: See TracChangeset
for help on using the changeset viewer.