Changeset 14 in text-formbuilder for trunk/lib/Text


Ignore:
Timestamp:
10/22/04 16:37:16 (20 years ago)
Author:
peter
Message:

added a !description directive
enabled showing checkboxes/radio groups as ulists when there are 3 or more options

Location:
trunk/lib/Text
Files:
2 edited

Legend:

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

    r12 r14  
    8787    } 
    8888 
    89 ##     #TODO: option switch for this 
    90 ##     #TODO: goes with CGI::FormBuilder 2.13 
    91 ##     foreach (@{ $self->{form_spec}{fields} }) { 
    92 ##         $$_{ulist} = 1 if $$_{type} and $$_{type} =~ /checkbox|radio/ and @{ $$_{options} } >= 3; 
    93 ##     } 
     89    foreach (@{ $self->{form_spec}{fields} }) { 
     90        $$_{ulist} = 1 if defined $$_{options} and @{ $$_{options} } >= 3; 
     91    } 
    9492     
    9593    $self->{form} = CGI::FormBuilder->new( 
     
    107105            }, 
    108106            data => { 
    109                 headings => $self->{form_spec}{headings}, 
    110                 author   => $self->{form_spec}{author}, 
     107                headings    => $self->{form_spec}{headings}, 
     108                author      => $self->{form_spec}{author}, 
     109                description => $self->{form_spec}{description}, 
    111110            }, 
    112111        }, 
     
    138137    my $title = $self->{form_spec}{title} || ''; 
    139138    my $author = $self->{form_spec}{author} || ''; 
     139    my $description = $self->{form_spec}{description} || ''; 
    140140    my $headings = Data::Dumper->Dump([$self->{form_spec}{headings}],['headings']); 
    141141    my $fields = Data::Dumper->Dump([ [ map { $$_{name} } @{ $self->{form_spec}{fields} } ] ],['fields']); 
     
    176176                headings => $headings, 
    177177                author   => q[$author], 
     178                description => q[$description], 
    178179            }, 
    179180        }, 
     
    229230    th h2 { padding: .125em .5em; background: #eee; } 
    230231    th.label { font-weight: normal; text-align: right; vertical-align: top; } 
     232    td ul { list-style: none; padding-left: 0; margin-left: 0; } 
    231233  </style> 
    232234</head> 
     
    235237<h1><% $title %></h1> 
    236238<% $author ? qq[<p id="author">Created by $author</p>] : '' %> 
     239<% $description ? qq[<p id="description">$description</p>] : '' %> 
    237240] . $self->_form_template . q[ 
    238241<hr /> 
  • trunk/lib/Text/FormBuilder/grammar

    r11 r14  
    1 { my ($title, $author, %lists, %patterns, @fields, @headings, $type, @options, $list_var, $size, $rows, $cols); } 
     1{ my ($title, $author, $description, %lists, %patterns, @fields, @headings, $type, @options, $list_var, $size, $rows, $cols); } 
    22 
    3 form_spec: (list_def | line)(s)  
     3form_spec: (list_def | description_def | line)(s)  
    44    { 
    55        $return = { 
    66            title    => $title, 
    77            author   => $author, 
     8            description => $description, 
    89            lists    => \%lists,  
    910            patterns => \%patterns,  
     
    2930 
    3031list_name: /[A-Z_]+/ 
     32 
     33description_def: '!description' <perl_codeblock> 
     34    { warn "[Text::FormBuilder] Description redefined at input text line $thisline\n" if defined $description; 
     35     
     36    $description = $item[2]; 
     37    $description =~ s/^{\s*|\s*}$//g; 
     38    } 
    3139 
    3240line: <skip:'[ \t]*'> ( title | author | pattern_def | heading | field | comment | blank ) "\n" 
Note: See TracChangeset for help on using the changeset viewer.