Changeset 64 in text-formbuilder for trunk/lib/Text/FormBuilder.pm
- Timestamp:
- 03/10/05 16:40:27 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Text/FormBuilder.pm
r63 r64 7 7 use vars qw($VERSION @EXPORT); 8 8 9 $VERSION = '0.09 _02';9 $VERSION = '0.09'; 10 10 @EXPORT = qw(create_form); 11 11 … … 235 235 236 236 # remove extraneous undefined values 237 # also check for approriate version of CGI::FormBuilder 238 # for some advanced options 239 my $FB_version = CGI::FormBuilder->VERSION; 237 240 for my $field (@{ $self->{form_spec}{fields} }) { 238 241 defined $$field{$_} or delete $$field{$_} foreach keys %{ $field }; 239 } 242 243 unless ($FB_version >= '3.002') { 244 if ($$field{growable}) { 245 warn '[' . (caller(0))[3] . "] growable fields not supported by FB $FB_version (requires 3.002)"; 246 delete $$field{growable}; 247 } 248 } 249 } 240 250 241 251 # remove false $$_{required} params because this messes up things at … … 243 253 # based on the existance of a 'required' param, not whether it is 244 254 # true or defined 255 # TODO: check if this is still needed 245 256 $$_{required} or delete $$_{required} foreach @{ $self->{form_spec}{fields} }; 246 257 258 # assign the field names to the sections 247 259 foreach (@{ $self->{form_spec}{sections} }) { 248 #for my $line (grep { $$_[0] eq 'field' } @{ $$_{lines} }) {249 260 for my $line (@{ $$_{lines} }) { 250 261 if ($$line[0] eq 'field') { 251 262 $$line[1] = $$line[1]{name}; 252 ## $_ eq 'name' or delete $$line[1]{$_} foreach keys %{ $$line[1] };253 ## } elsif ($$line[0] eq 'group') {254 ## $$line[1] = [ map { $$_{name} } @{ $$line[1]{group} } ];255 263 } 256 264 } … … 353 361 my %module_subs; 354 362 my $d = Data::Dumper->new([ \%options ], [ '*options' ]); 355 356 use B::Deparse;357 my $deparse = B::Deparse->new;358 ##359 ## #TODO: need a workaround/better solution since Data::Dumper doesn't like dumping coderefs360 ## foreach (@{ $self->{form_spec}{fields} }) {361 ## if (ref $$_{validate} eq 'CODE') {362 ## my $body = $deparse->coderef2text($$_{validate});363 ## #$d->Seen({ "*_validate_$$_{name}" => $$_{validate} });364 ## #$module_subs{$$_{name}} = "sub _validate_$$_{name} $$_{validate}";365 ## }366 ## }367 ## my $sub_code = join("\n", each %module_subs);368 363 369 364 my $form_options = keys %options > 0 ? $d->Dump : ''; … … 1058 1053 given). Growable fields have a button that allows the user to add a 1059 1054 copy of the field input. Currently, this only works for C<text> and 1060 C<file> fields . Growable fields also require JavaScript to function1061 correctly.1055 C<file> fields, and you must have L<CGI::FormBuilder> 3.02 or higher. 1056 Growable fields also require JavaScript to function correctly. 1062 1057 1063 1058 # you can have as many people as you like … … 1088 1083 1089 1084 month:select@MONTHS 1090 1091 There is another form of the C<!list> directive: the dynamic list:1092 1093 !list RANDOM &{ map { rand } (0..5) }1094 1095 The code inside the C<&{ ... }> is C<eval>ed by C<build>, and the results1096 are stuffed into the list. The C<eval>ed code can either return a simple1097 list, as the example does, or the fancier C<< ( { value1 => 'Description 1'},1098 { value2 => 'Description 2}, ... ) >> form.1099 1100 I<B<NOTE:> This feature of the language may go away unless I find a compelling1101 reason for it in the next few versions. What I really wanted was lists that1102 were filled in at run-time (e.g. from a database), and that can be done easily1103 enough with the CGI::FormBuilder object directly.>1104 1085 1105 1086 If you want to have a single checkbox (e.g. for a field that says ``I want to … … 1181 1162 Document the commmand line tool 1182 1163 1164 Document use of the parser as a standalone module 1165 1183 1166 Allow renaming of the submit button; allow renaming and inclusion of a 1184 1167 reset button
Note: See TracChangeset
for help on using the changeset viewer.