Changeset 63 in text-formbuilder for trunk


Ignore:
Timestamp:
02/18/05 11:26:45 (19 years ago)
Author:
peichman
Message:

field groups can be directly named as the type in a fieldspec

Location:
trunk/lib/Text
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Text/FormBuilder.pm

    r61 r63  
    99$VERSION = '0.09_02'; 
    1010@EXPORT = qw(create_form); 
     11 
     12#$::RD_TRACE = 1; 
    1113 
    1214use Carp; 
     
    1719my %DEFAULT_OPTIONS = ( 
    1820    method => 'GET', 
    19 ##     javascript => 1, 
    2021    keepextras => 1, 
    2122); 
     
    226227    } 
    227228     
    228     # use the list for displaying checkbox groups 
     229    # use columns for displaying checkbox fields larger than 2 items 
    229230    foreach (@{ $self->{form_spec}{fields} }) { 
    230231        if (ref $$_{options} and @{ $$_{options} } >= 3) { 
     
    535536                $OUT .= qq[    <td><span class="fieldgroup">]; 
    536537                $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; 
    538540                 
    539541                $OUT .= qq[    </span></td>\n]; 
     
    11621164C<birthday_day>, and C<birthday_year>. 
    11631165 
     1166You can also use groups in normal field lines: 
     1167     
     1168    birthday|Your birthday:DATE 
     1169 
     1170The only (currently) supported pieces of a fieldspec that may be used with a 
     1171group in this notation are name and label. 
     1172 
    11641173=head2 Comments 
    11651174 
     
    11751184reset button 
    11761185 
    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 
     1186Allow comments on group fields (rendered after the all the fields) 
    11861187 
    11871188Pieces that wouldn't make sense in a group field: size, row/col, options, 
  • trunk/lib/Text/FormBuilder/grammar

    r62 r63  
    104104 
    105105field_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" 
     106line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | group_field | field_group | unknown_directive | field | comment | blank ) "\n" 
    107107 
    108108title: '!title' /.*/ 
     
    151151group_name: /%[A-Z_]+/ 
    152152 
     153field_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 
     159group_type: ':' var_name 
     160 
    153161field: name field_size(?) growable(?) label(?) hint(?) type(?) default(?) option_list(?) validate(?) 
    154162    { 
     
    160168            type     => $item{'type(?)'}[0], 
    161169            value    => $item{'default(?)'}[0], 
    162             list     => $list_var, 
    163             validate => $item{'validate(?)'}[0], 
     170            list     => $list_var, 
     171            validate => $item{'validate(?)'}[0], 
    164172            required => $required || 0, 
    165173        }; 
     
    187195        $maxlength = undef; 
    188196        @options = (); 
    189          
     197         
    190198        $field; 
    191199    } 
     
    211219hint: '[' /[^\]]+/ ']'    { $item[2] } 
    212220 
    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' } ) 
     221type: ':' builtin_field 
    215222 
    216223builtin_field: /textarea|text|password|file|checkbox|radio|select|hidden|static/ 
Note: See TracChangeset for help on using the changeset viewer.