Changeset 50 in text-formbuilder
- Timestamp:
- 12/16/04 13:55:34 (20 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Changes
r46 r50 1 1 Release history for Text::FormBuilder. 2 2 3 0.07 3 0.07 - 16 Dec 2004 4 4 * added a create_form exported method to "do the right 5 5 thing" in simple cases … … 10 10 script around the FormBuilder object 11 11 * added external documentation of usage examples 12 * added a !note directive for inserting arbitrary text 13 between lines in the form 12 14 13 15 0.06 - 19 Nov 2004 -
trunk/lib/Text/FormBuilder.pm
r46 r50 7 7 use vars qw($VERSION @EXPORT); 8 8 9 $VERSION = '0.07 _03';9 $VERSION = '0.07'; 10 10 @EXPORT = qw(create_form); 11 11 … … 30 30 th.label { font-weight: normal; text-align: right; vertical-align: top; } 31 31 td ul { list-style: none; padding-left: 0; margin-left: 0; } 32 .note { background: #eee; } 32 33 .sublabel { color: #999; } 33 34 .invalid { background: red; } … … 246 247 } 247 248 249 # get user-defined lists; can't make this conditional because 250 # we need to be able to fall back to CGI::FormBuilder's lists 251 # even if the user didn't define any 252 my %lists = %{ $self->{form_spec}{lists} || {} }; 253 248 254 # substitute in list names 249 if (my %lists = %{ $self->{form_spec}{lists} || {} }) { 250 foreach (@{ $self->{form_spec}{fields} }) { 251 next unless $$_{list}; 252 253 $$_{list} =~ s/^\@//; # strip leading @ from list var name 254 255 # a hack so we don't get screwy reference errors 256 if (exists $lists{$$_{list}}) { 257 my @list; 258 push @list, { %$_ } foreach @{ $lists{$$_{list}} }; 259 $$_{options} = \@list; 260 } else { 261 # assume that the list name is a builtin 262 # and let it fall through to CGI::FormBuilder 263 $$_{options} = $$_{list}; 264 } 265 } continue { 266 delete $$_{list}; 255 foreach (@{ $self->{form_spec}{fields} }) { 256 next unless $$_{list}; 257 258 $$_{list} =~ s/^\@//; # strip leading @ from list var name 259 260 # a hack so we don't get screwy reference errors 261 if (exists $lists{$$_{list}}) { 262 my @list; 263 push @list, { %$_ } foreach @{ $lists{$$_{list}} }; 264 $$_{options} = \@list; 265 } else { 266 # assume that the list name is a builtin 267 # and let it fall through to CGI::FormBuilder 268 $$_{options} = $$_{list}; 267 269 } 270 } continue { 271 delete $$_{list}; 268 272 } 269 273 … … 535 539 if ($$line[0] eq 'head') { 536 540 $OUT .= qq[ <tr><th class="subhead" colspan="2"><h3>$$line[1]</h3></th></tr>\n] 541 } elsif ($$line[0] eq 'note') { 542 $OUT .= qq[ <tr><td class="note" colspan="2">$$line[1]</td></tr>\n] 537 543 } elsif ($$line[0] eq 'field') { 538 544 local $_ = $field{$$line[1]}; … … 959 965 960 966 !head ... 967 968 !note { 969 ... 970 } 961 971 962 972 =head2 Directives … … 983 993 =item C<!title> 984 994 995 Title of the form. 996 985 997 =item C<!author> 998 999 Author of the form. 986 1000 987 1001 =item C<!description> … … 1001 1015 next to each other. 1002 1016 1017 =item C<!note> 1018 1019 A text note that can be inserted as a row in the form. This is useful for 1020 special instructions at specific points in a long form. 1021 1003 1022 =back 1023 1024 B<Known BUG:> If you include an odd number of C<'> or C<"> characters in a 1025 C<!description> or C<!note>, then that directive will mistakenly be skipped. 1026 This is a bug casued by me taking a shortcut in the parser C<:-/> 1004 1027 1005 1028 =head2 Fields … … 1185 1208 =head1 BUGS 1186 1209 1210 Having a single C<'> or C<"> in a C<!description> or C<!note> directive causes that 1211 directive to get skipped. This is an issue with the C<perl_codeblock> shortcut in 1212 Parse::RecDescent. 1213 1187 1214 Creating two $parsers in the same script causes the second one to get the data 1188 1215 from the first one. … … 1194 1221 =head1 SEE ALSO 1195 1222 1196 L<CGI::FormBuilder> 1223 L<http://textformbuilder.berlios.de> 1224 1225 L<CGI::FormBuilder>, L<http://formbuilder.org> 1197 1226 1198 1227 =head1 THANKS -
trunk/lib/Text/FormBuilder/grammar
r42 r50 25 25 } 26 26 27 form_spec: (list_def | description_def | validate_def | group_def | line)(s)27 form_spec: (list_def | description_def | validate_def | group_def | note | line)(s) 28 28 { 29 29 # grab the last section, if there is any … … 84 84 } 85 85 86 note: '!note' <perl_codeblock> 87 { 88 (my $note = $item[2]) =~ s/^{\s*|\s*}$//g; 89 push @lines, [ 'note', $note ]; 90 } 91 92 86 93 field_line: <skip:'[ \t]*'> ( field | comment | blank ) "\n" 87 94 line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | group_field | unknown_directive | field | comment | blank ) "\n"
Note: See TracChangeset
for help on using the changeset viewer.