Changeset 80 in text-formbuilder for trunk


Ignore:
Timestamp:
04/12/05 11:23:36 (19 years ago)
Author:
peichman
Message:

added a !submit directive to rename the submit button or to have multiple submit buttons
upped version number

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Changes

    r78 r80  
    11Release history for Text::FormBuilder. 
    22 
     30.11 
     4    * added a !submit directive to rename the submit button or to 
     5      have multiple submit buttons 
     6     
    370.10 - 25 Mar 2005 
    48    * added support for fields with 'other' (requires FB 3.02) 
  • trunk/lib/Text/FormBuilder.pm

    r77 r80  
    77use vars qw($VERSION @EXPORT); 
    88 
    9 $VERSION = '0.10'; 
     9$VERSION = '0.11_01'; 
    1010@EXPORT = qw(create_form); 
    1111 
     
    296296        title => $self->{form_spec}{title}, 
    297297        text  => $self->{form_spec}{description}, 
     298        submit => $self->{form_spec}{submit}, 
    298299        template => { 
    299300            type => 'Text', 
     
    963964        ... 
    964965    } 
     966     
     967    !submit button label, button label 2, ... 
    965968 
    966969=head2 Directives 
     
    10131016A text note that can be inserted as a row in the form. This is useful for 
    10141017special instructions at specific points in a long form. 
     1018 
     1019=item C<!submit> 
     1020 
     1021A list of one or more submit button labels in a comma-separated list. Each label 
     1022is a L<string|/Strings>. Multiple instances of this directive may be used; later 
     1023lists are simply appended to the earlier lists. All the submit buttons are  
     1024rendered together at the bottom of the form. See L<CGI::FormBuilder> for an 
     1025explanation of how the multiple submit buttons work together in a form. 
    10151026 
    10161027=back 
     
    10991110    person*:text 
    11001111 
     1112To set a limit to the maximum number of inputs a field can grow to, add 
     1113a number after the C<*>: 
     1114 
     1115    # allow up to 5 musicians 
     1116    musician*5:text 
     1117 
    11011118To create a C<radio> or C<select> field that includes an "other" option, 
    11021119append the string C<+other> to the field type: 
     
    12231240=head2 Language/Parser 
    12241241 
     1242Debug flag (that sets/unsets C<$::RD_TRACE> in the parser) 
     1243 
    12251244Make sure that multiple runs of the parser don't share data. 
    12261245 
    1227 Allow renaming of the submit button; allow renaming and inclusion of a  
    1228 reset button 
     1246Allow renaming and inclusion of a reset button 
     1247 
     1248Warn/suggest using the C<!submit> directive if some uses C<foo:submit>? 
    12291249 
    12301250Set FB constructor options directly in the formspec (via a C<!fb> or similar 
     
    12451265option to C<< FB->new >>; will require FB 3.02 to run. 
    12461266 
    1247 Better integration with L<CGI::FormBuilder>'s templating system 
     1267Better integration with L<CGI::FormBuilder>'s templating system; rely on the 
     1268FB messages instead of trying to make our own. 
    12481269 
    12491270Allow for custom wrappers around the C<form_template> 
  • trunk/lib/Text/FormBuilder/grammar

    r77 r80  
    2424        $rows, 
    2525        $cols, 
     26        @submit, 
    2627    ); 
    2728    my $context = 'line';       # start in line context by default 
     
    3839        %formspec = ();  # clear the old formspec data 
    3940    } 
    40     (list_def | description_def | group_def | note | line)(s) 
     41    (list_def | description_def | group_def | note | unknown_block_directive | line)(s) 
    4142    { 
    4243        # grab the last section, if there is any 
     
    5960            groups   => \%groups, 
    6061            sections => \@sections, 
     62            ( @submit ?  
     63                (submit => @submit == 1 ? $submit[0] : \@submit) : 
     64                () 
     65            ), 
    6166        } 
    6267    } 
     
    106111field_line: <skip:'[ \t]*'> ( field | comment | blank ) "\n" 
    107112 
    108 line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | group_field | field_group | unknown_directive | field | comment | blank ) "\n" 
     113line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | submit | group_field | field_group | unknown_directive | field | comment | blank ) /\n+/ 
    109114 
    110115title: '!title' /.*/ 
     
    145150 
    146151heading: '!head' /.*/    { push @lines, [ 'head', $item[2] ] } 
     152 
     153submit: '!submit' string(s /\s*,\s*/) 
     154    { 
     155        #warn scalar(@{ $item[2] }) . ' submit button(s)'; 
     156        push @submit, @{ $item[2] }; 
     157    } 
    147158 
    148159group_field: '!field' group_name name label(?) 
     
    243254 
    244255# for simple multiword values not involving punctuation 
    245 simple_multiword: <skip:''> /\w[\w\t ]*/ { $item[2] } 
     256simple_multiword: /\w/ <skip:''> /[\w\t ]*/ { $item[1] . $item[3] } 
    246257 
    247258# my attempt at a single-quoted, non-interpolating string 
    248259# where the backslash can escape literal single quotes 
    249 quoted_string: <skip:''> "'" /(\\'|[^'])*/ "'" 
     260quoted_string: "'" <skip:''> /(\\'|[^'])*/ "'" 
    250261    { $item[3] =~ s/\\'/'/g; $item[3] } 
    251262 
     
    278289unknown_directive: /\!\S*/ /.*/ 
    279290    { warn "[Text::Formbuilder] Skipping unknown directive '$item[1]' at input text line $thisline\n"; } 
     291 
     292unknown_block_directive: /\!\S*/ var_name(?) block 
     293    { warn "[Text::Formbuilder] Skipping unknown block directive '$item[1]' at input text line $thisline\n"; } 
Note: See TracChangeset for help on using the changeset viewer.