Changeset 7 in text-formbuilder
- Timestamp:
- 10/06/04 13:44:15 (20 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.PL
r4 r7 8 8 EXE_FILES => [ 'bin/fb.pl' ], 9 9 PREREQ_PM => { 10 Parse::RecDescent => 1.94,11 10 CGI::FormBuilder => 2.12, 12 YAML => 0.35,13 11 }, # e.g., Module::Name => 1.1 14 12 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 -
trunk/bin/fb-cgi.pl
r1 r7 12 12 my $form = $parser->parse($src_file)->build(method => 'POST', params => $q)->form; 13 13 14 if ( $form->submitted && $form->validate) {15 # TODO: 14 if (1 or $form->submitted && $form->validate) { 15 16 16 # call storage function 17 17 18 my $plugin = 'DumpParams'; 19 18 20 eval "use $plugin;"; 19 20 if ($plugin->process($q)) { 21 die "Can't use $plugin; $@" if $@; 22 die "Plugin $plugin doesn't know how to process" unless $plugin->can('process'); 23 24 # plugin process method should return a true value 25 if ($plugin->process($q, $form)) { 21 26 # show thank you page 22 #print $q->header('text/plain');23 #print "Thank you for your input!\n"24 27 } else { 25 28 # there was an error processing the results 29 die "There was an error processing the submission: " . $plugin->error; 26 30 } 27 31 -
trunk/lib/Text/FormBuilder.pm
r1 r7 4 4 use warnings; 5 5 6 our $VERSION = '0.0 1';6 our $VERSION = '0.02'; 7 7 8 8 use Text::FormBuilder::Parser; 9 9 use CGI::FormBuilder; 10 use YAML;11 10 12 11 sub new { … … 153 152 } 154 153 155 sub _dump { print YAML::Dump(shift->{form_spec}); } 154 sub dump { 155 eval "use YAML;"; 156 unless ($@) { 157 print YAML::Dump(shift->{form_spec}); 158 } else { 159 warn "Can't dump form spec structure: $@"; 160 } 161 } 156 162 157 163 … … 170 176 # returns a new CGI::FormBuilder object with the fields 171 177 # from the input form spec 172 my $form = $parser-> build_form;178 my $form = $parser->form; 173 179 174 180 =head1 DESCRIPTION … … 178 184 =head2 parse 179 185 186 $parser->parse($src_file); 187 188 # or as a class method 189 my $parser = Txt::FormBuilder->parse($src_file); 190 191 =head2 parse_text 192 180 193 =head2 build 181 194 195 Options passed to build are passed on verbatim to the L<CGI::FormBuilder> 196 constructor. Any options given here override the defaults that this module 197 uses. 198 199 =head2 form 200 201 my $form = $parser->form; 202 203 Returns the L<CGI::FormBuilder> object. 204 182 205 =head2 write 183 206 207 $parser->write($out_file); 208 # or just print to STDOUT 209 $parser->write; 210 211 Calls C<render> on the FormBuilder form, and either writes the resulting HTML 212 to a file, or to STDOUT if no filename is given. 213 214 =head2 dump 215 216 Uses L<YAML> to print out a human-readable representaiton of the parsed 217 form spec. 218 184 219 =head1 LANGUAGE 185 220 186 name[size]|descriptive label[hint]:type=default{option1 (display string),option2(display string),...}//validate221 name[size]|descriptive label[hint]:type=default{option1[display string],option2[display string],...}//validate 187 222 188 223 !title ... … … 190 225 !pattern name /regular expression/ 191 226 !list name { 192 option1 (display string),193 option2 (display string),227 option1[display string], 228 option2[display string], 194 229 ... 195 230 } … … 204 239 205 240 =item C<!title> 241 242 =item C<!author> 206 243 207 244 =back … … 220 257 Any line beginning with a C<#> is considered a comment. 221 258 259 =head1 TODO 260 261 =head2 Langauge 262 263 Directive for a descriptive or explanatory paragraph about the form 264 265 Subsection headers? 266 222 267 =head1 SEE ALSO 223 268
Note: See TracChangeset
for help on using the changeset viewer.