Changeset 25 in text-formbuilder
- Timestamp:
- 11/16/04 15:34:57 (20 years ago)
- Location:
- trunk/lib/Text
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Text/FormBuilder.pm
r24 r25 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 }87 ## # so we don't get all fields required 88 ## foreach (@{ $self->{form_spec}{fields} }) { 89 ## delete $$_{validate} unless $$_{validate}; 90 ## } 91 91 92 92 # expand groups … … 117 117 118 118 # substitute in list names 119 if (my %lists = %{ $self->{form_spec}{lists} || {} }) { 120 foreach (@{ $self->{form_spec}{fields} }) { 121 next unless $$_{list}; 122 123 $$_{list} =~ s/^\@//; # strip leading @ from list var name 124 125 # a hack so we don't get screwy reference errors 126 if (exists $lists{$$_{list}}) { 127 my @list; 128 push @list, { %$_ } foreach @{ $lists{$$_{list}} }; 129 $$_{options} = \@list; 130 } 131 } continue { 132 delete $$_{list}; 119 my %lists = %{ $self->{form_spec}{lists} }; 120 foreach (@{ $self->{form_spec}{fields} }) { 121 next unless $$_{list}; 122 123 $$_{list} =~ s/^\@//; # strip leading @ from list var name 124 125 # a hack so we don't get screwy reference errors 126 if (exists $lists{$$_{list}}) { 127 my @list; 128 push @list, { %$_ } foreach @{ $lists{$$_{list}} }; 129 $$_{options} = \@list; 130 } else { 131 ## #TODO: this is not working in CGI::FormBuilder 132 ## # assume that the list name is a builtin 133 ## # and let it fall through to CGI::FormBuilder 134 ## $$_{options} = $$_{list}; 135 ## warn "falling through to builtin $$_{options}"; 133 136 } 134 } 135 137 } continue { 138 delete $$_{list}; 139 } 136 140 137 141 # TODO: configurable threshold for this … … 155 159 required => [ map { $$_{name} } grep { $$_{required} } @{ $self->{form_spec}{fields} } ], 156 160 title => $self->{form_spec}{title}, 161 text => $self->{form_spec}{description}, 157 162 template => { 158 163 type => 'Text', … … 222 227 %DEFAULT_OPTIONS, 223 228 title => $self->{form_spec}{title}, 229 text => $self->{form_spec}{description}, 224 230 required => [ map { $$_{name} } grep { $$_{required} } @{ $self->{form_spec}{fields} } ], 225 231 template => { -
trunk/lib/Text/FormBuilder/grammar
r24 r25 29 29 author => $author, 30 30 description => $description, 31 lists => \%lists ,32 patterns => \%patterns ,33 headings => \@headings ,34 fields => \@fields ,35 lines => \@lines ,36 groups => \%groups ,31 lists => \%lists || {}, 32 patterns => \%patterns || {}, 33 headings => \@headings || [], 34 fields => \@fields || [], 35 lines => \@lines || [], 36 groups => \%groups || {}, 37 37 } 38 38 } … … 169 169 list_var: /@[A-Z_]+/ { $list_var = $item[1] } 170 170 171 option: ( value | simple_multiword| quoted_string) display_text(?)171 option: (simple_multiword | value | quoted_string) display_text(?) 172 172 { push @options, { $item[1] => $item{'display_text(?)'}[0] } } 173 173
Note: See TracChangeset
for help on using the changeset viewer.