Changeset 81 in text-formbuilder


Ignore:
Timestamp:
04/13/05 11:34:05 (20 years ago)
Author:
peichman
Message:

added a !reset directive to name and include a reset button

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Changes

    r80 r81  
    22 
    330.11 
     4    * added a !reset directive to name and include a reset button 
    45    * added a !submit directive to rename the submit button or to 
    56      have multiple submit buttons 
  • trunk/lib/Text/FormBuilder.pm

    r80 r81  
    296296        title => $self->{form_spec}{title}, 
    297297        text  => $self->{form_spec}{description}, 
    298         submit => $self->{form_spec}{submit}, 
     298        # use 'defined' so we are able to differentiate between 'submit = 0' (no submit button) 
     299        # and 'submit = undef' (use default submit button) 
     300        ( defined $self->{form_spec}{submit} ? (submit => $self->{form_spec}{submit}) : () ), 
     301        reset => $self->{form_spec}{reset}, 
    299302        template => { 
    300303            type => 'Text', 
     
    305308            }, 
    306309            data => { 
     310                #TODO: make FB aware of sections 
    307311                sections    => $self->{form_spec}{sections}, 
    308312                author      => $self->{form_spec}{author}, 
     
    534538                # mark invalid fields 
    535539                if ($$_{invalid}) { 
    536                     $OUT .= qq[<td>$$_{field} <span class="comment">$$_{comment}</span> ] . $msg_invalid . q[</td>]; 
     540                    $OUT .= qq[<td>$$_{field} <span class="comment">$$_{comment}</span> $$_{error}</td>]; 
    537541                } else { 
    538542                    $OUT .= qq[<td>$$_{field} <span class="comment">$$_{comment}</span></td>]; 
     
    551555                $OUT .= qq[    <td><span class="fieldgroup">]; 
    552556                $OUT .= join(' ', map { qq[<small class="sublabel">$$_{label}</small> $$_{field} $$_{comment}] } @group_fields); 
    553                 #TODO: allow comments on field groups 
    554                 $OUT .= " ] . $msg_invalid . q[" if grep { $$_{invalid} } @group_fields; 
    555                  
     557                if (my @invalid = grep { $$_{invalid} } @group_fields) { 
     558                    $OUT .= ' ' . join('; ', map { $$_{error} } @invalid); 
     559                }                 
    556560                $OUT .= qq[ <span class="comment">$$line[1]{comment}</span></span></td>\n]; 
    557561                $OUT .= qq[  </tr>\n]; 
     
    566570    } 
    567571%> 
    568   <tr><th></th><td style="padding-top: 1em;"><% $submit %></td></tr> 
     572  <tr><th></th><td style="padding-top: 1em;"><% $submit %> <% $reset %></td></tr> 
    569573</table> 
    570574</fieldset> 
     
    965969    } 
    966970     
    967     !submit button label, button label 2, ... 
     971    !submit label, label 2, ... 
     972     
     973    !reset label 
    968974 
    969975=head2 Directives 
     
    10241030rendered together at the bottom of the form. See L<CGI::FormBuilder> for an 
    10251031explanation of how the multiple submit buttons work together in a form. 
     1032 
     1033To disable the display of any submit button, use C<!submit 0> 
     1034 
     1035=item C<!reset> 
     1036 
     1037The label for the a reset button at the end of the form. No reset button will be 
     1038rendered unless you use this directive. 
    10261039 
    10271040=back 
     
    12441257Make sure that multiple runs of the parser don't share data. 
    12451258 
    1246 Allow renaming and inclusion of a reset button 
    1247  
    12481259Warn/suggest using the C<!submit> directive if some uses C<foo:submit>? 
    12491260 
  • trunk/lib/Text/FormBuilder/grammar

    r80 r81  
    6464                () 
    6565            ), 
     66            reset => $formspec{reset}, 
    6667        } 
    6768    } 
     
    111112field_line: <skip:'[ \t]*'> ( field | comment | blank ) "\n" 
    112113 
    113 line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | submit | group_field | field_group | unknown_directive | field | comment | blank ) /\n+/ 
     114line: <skip:'[ \t]*'> ( title | author | pattern_def | section_head | heading | submit | reset | group_field | field_group | unknown_directive | field | comment | blank ) /\n+/ 
    114115 
    115116title: '!title' /.*/ 
     
    155156        #warn scalar(@{ $item[2] }) . ' submit button(s)'; 
    156157        push @submit, @{ $item[2] }; 
     158    } 
     159 
     160reset: '!reset' string 
     161    { 
     162        warn "[Text::FormBuilder] Reset button redefined at input text line $thisline\n" if defined $formspec{reset}; 
     163        $formspec{reset} = $item{string}; 
    157164    } 
    158165 
Note: See TracChangeset for help on using the changeset viewer.