Changeset 25 in text-formbuilder for trunk


Ignore:
Timestamp:
11/16/04 15:34:57 (20 years ago)
Author:
peter
Message:

tried adding fall-through to built-in option lists but not yet working
minor tweak to the grammar for option lists (put wimple_multiword in front of value)

Location:
trunk/lib/Text
Files:
2 edited

Legend:

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

    r24 r25  
    7777     
    7878    # substitute in custom pattern definitions for field validation 
    79     if (my %patterns = %{ $self->{form_spec}{patterns} || {} }) { 
     79    if (my %patterns = %{ $self->{form_spec}{patterns} }) { 
    8080        foreach (@{ $self->{form_spec}{fields} }) { 
    8181            if ($$_{validate} and exists $patterns{$$_{validate}}) { 
     
    8585    } 
    8686     
    87     # so we don't get all fields required 
    88     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##     } 
    9191 
    9292    # expand groups 
     
    117117     
    118118    # 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}"; 
    133136        } 
    134     } 
    135      
     137    } continue { 
     138        delete $$_{list}; 
     139    }     
    136140     
    137141    # TODO: configurable threshold for this 
     
    155159        required => [ map { $$_{name} } grep { $$_{required} } @{ $self->{form_spec}{fields} } ], 
    156160        title => $self->{form_spec}{title}, 
     161        text  => $self->{form_spec}{description}, 
    157162        template => { 
    158163            type => 'Text', 
     
    222227        %DEFAULT_OPTIONS, 
    223228        title => $self->{form_spec}{title}, 
     229        text  => $self->{form_spec}{description}, 
    224230        required => [ map { $$_{name} } grep { $$_{required} } @{ $self->{form_spec}{fields} } ], 
    225231        template => { 
  • trunk/lib/Text/FormBuilder/grammar

    r24 r25  
    2929            author   => $author, 
    3030            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   || {}, 
    3737        } 
    3838    } 
     
    169169list_var: /@[A-Z_]+/ { $list_var = $item[1] } 
    170170 
    171 option: (value | simple_multiword | quoted_string) display_text(?) 
     171option: (simple_multiword | value | quoted_string) display_text(?) 
    172172    { push @options, { $item[1] => $item{'display_text(?)'}[0] } } 
    173173 
Note: See TracChangeset for help on using the changeset viewer.