Changeset 56 in text-formbuilder for trunk


Ignore:
Timestamp:
01/13/05 15:00:25 (19 years ago)
Author:
peichman
Message:

single-line textfields can be given a maxlength

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Changes

    r53 r56  
    11Release history for Text::FormBuilder. 
    22 
     30.09 
     4    * single-line textfields can be given a maxlength 
     5     
    360.08 - 10 Jan 2005 
    47    * failure to load Perl::Tidy is no longer fatal 
  • trunk/lib/Text/FormBuilder.pm

    r55 r56  
    624624=head1 REQUIRES 
    625625 
    626 L<Parse::RecDescent>, L<CGI::FormBuilder>, L<Text::Template> 
     626L<Parse::RecDescent>, 
     627L<CGI::FormBuilder>, 
     628L<Text::Template>, 
     629L<Class::Base> 
    627630 
    628631=head1 DESCRIPTION 
     
    10431046    description[4,30]:textarea 
    10441047 
     1048To also set the C<maxlength> attribute for text fields, add a C<!> after 
     1049the size: 
     1050 
     1051    # ensure that all titles entered are 40 characters or less 
     1052    title[40!]:text 
     1053 
     1054This currently only works for single line text fields. 
     1055     
    10451056For the input types that can have options (C<select>, C<radio>, and 
    10461057C<checkbox>), here's how you do it: 
  • trunk/lib/Text/FormBuilder/grammar

    r55 r56  
    1919        $list_var, 
    2020        $size, 
     21        $maxlength, 
    2122        $rows, 
    2223        $cols, 
     
    157158        $$field{cols} = $cols if defined $cols; 
    158159        $$field{size} = $size if defined $size; 
     160        $$field{maxlength} = $maxlength if defined $maxlength; 
    159161         
    160162        #warn "[$thisline] field $item{name}; context $context\n"; 
     
    171173        $rows = undef; 
    172174        $cols = undef; 
     175        $maxlength = undef; 
    173176        @options = (); 
    174177         
     
    181184field_size: '[' ( row_col | size ) ']' 
    182185 
    183 size: /\d+/ 
    184     { $size = $item[1] } 
     186size: /\d+/ bang(?) 
     187    { $maxlength = $item[1] if $item[2][0]; $size = $item[1] } 
     188 
     189bang: '!' 
    185190 
    186191row_col: /\d+/ /,\s*/ /\d+/ 
Note: See TracChangeset for help on using the changeset viewer.