Changeset 63 in text-formbuilder
- Timestamp:
- 02/18/05 11:26:45 (20 years ago)
- Location:
- trunk/lib/Text
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Text/FormBuilder.pm
r61 r63 9 9 $VERSION = '0.09_02'; 10 10 @EXPORT = qw(create_form); 11 12 #$::RD_TRACE = 1; 11 13 12 14 use Carp; … … 17 19 my %DEFAULT_OPTIONS = ( 18 20 method => 'GET', 19 ## javascript => 1,20 21 keepextras => 1, 21 22 ); … … 226 227 } 227 228 228 # use the list for displaying checkbox groups229 # use columns for displaying checkbox fields larger than 2 items 229 230 foreach (@{ $self->{form_spec}{fields} }) { 230 231 if (ref $$_{options} and @{ $$_{options} } >= 3) { … … 535 536 $OUT .= qq[ <td><span class="fieldgroup">]; 536 537 $OUT .= join(' ', map { qq[<small class="sublabel">$$_{label}</small> $$_{field} $$_{comment}] } @group_fields); 537 $OUT .= " ] . $msg_invalid . q[" if $$_{invalid}; 538 #TODO: allow comments on field groups 539 $OUT .= " ] . $msg_invalid . q[" if grep { $$_{invalid} } @group_fields; 538 540 539 541 $OUT .= qq[ </span></td>\n]; … … 1162 1164 C<birthday_day>, and C<birthday_year>. 1163 1165 1166 You can also use groups in normal field lines: 1167 1168 birthday|Your birthday:DATE 1169 1170 The only (currently) supported pieces of a fieldspec that may be used with a 1171 group in this notation are name and label. 1172 1164 1173 =head2 Comments 1165 1174 … … 1175 1184 reset button 1176 1185 1177 Allow groups to be used in normal field lines something like this: 1178 1179 !group DATE { 1180 month 1181 day 1182 year 1183 } 1184 1185 dob|Your birthday:DATE 1186 Allow comments on group fields (rendered after the all the fields) 1186 1187 1187 1188 Pieces that wouldn't make sense in a group field: size, row/col, options, -
trunk/lib/Text/FormBuilder/grammar
r62 r63 104 104 105 105 field_line: <skip:'[ \t]*'> ( field | comment | blank ) "\n" 106 line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | group_field | unknown_directive | field | comment | blank ) "\n"106 line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | group_field | field_group | unknown_directive | field | comment | blank ) "\n" 107 107 108 108 title: '!title' /.*/ … … 151 151 group_name: /%[A-Z_]+/ 152 152 153 field_group: name label(?) group_type 154 { 155 #warn "[$thisline] field $item{name} is $item{group_type}\n"; 156 push @lines, [ 'group', { name => $item{name}, label => $item{'label(?)'}[0], group => $item{group_type} } ]; 157 } 158 159 group_type: ':' var_name 160 153 161 field: name field_size(?) growable(?) label(?) hint(?) type(?) default(?) option_list(?) validate(?) 154 162 { … … 160 168 type => $item{'type(?)'}[0], 161 169 value => $item{'default(?)'}[0], 162 163 170 list => $list_var, 171 validate => $item{'validate(?)'}[0], 164 172 required => $required || 0, 165 173 }; … … 187 195 $maxlength = undef; 188 196 @options = (); 189 197 190 198 $field; 191 199 } … … 211 219 hint: '[' /[^\]]+/ ']' { $item[2] } 212 220 213 # TODO: differentiate between builtins and custom field groups 214 type: ':' ( builtin_field | var_name { warn "[Text::FormBuilder] Using field group names directly is not (yet) supported (input line $thisline)\n"; 'text' } ) 221 type: ':' builtin_field 215 222 216 223 builtin_field: /textarea|text|password|file|checkbox|radio|select|hidden|static/
Note: See TracChangeset
for help on using the changeset viewer.