- Timestamp:
- 03/16/05 16:16:30 (20 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Changes
r73 r74 8 8 * using <fieldset> tags instead of <h2> to mark form sections 9 9 * group fields can have comments 10 * deprecated the !field directive 10 11 11 12 0.09 - 10 Mar 2005 -
trunk/lib/Text/FormBuilder.pm
r73 r74 820 820 CGI script to render the form. This way, you only need CGI::FormBuilder on 821 821 your server, and you don't have to parse the form spec each time you want 822 to display your form. The generated module has one function (not exported)823 called C<get_form>, that takes a CGI object as its only argument, and returns 824 a CGI::FormBuilder object.822 to display your form. The generated module is a subclass of L<CGI::FormBuilder>, 823 that will passa long any constructor arguments to FormBuilder, and set up 824 the fields for you. 825 825 826 826 First, you parse the formspec and write the module, which you can do as a one-liner: … … 828 828 $ perl -MText::FormBuilder -e"Text::FormBuilder->parse('formspec.txt')->write_module('My::Form')" 829 829 830 B<FIXME>And then, in your CGI script, use the new module:830 And then, in your CGI script, use the new module: 831 831 832 832 #!/usr/bin/perl -w … … 837 837 838 838 my $q = CGI->new; 839 my $form = My::Form ::get_form($q);839 my $form = My::Form->new; 840 840 841 841 # do the standard CGI::FormBuilder stuff … … 868 868 use warnings; 869 869 870 use CGI;871 870 use CGI::FormBuilder; 872 871 873 my $q = CGI->new;874 875 872 my $form = CGI::FormBuilder->new( 876 params => $q, 877 # ... lots of other stuff to set up the form ... 873 # lots of stuff here... 878 874 ); 879 875 880 $form->field( name => 'month' );881 $form->field( name => 'day');882 883 unless ( $form->submitted && $form->validate) {876 # ...and your field setup subs are here 877 $form->field(name => '...'); 878 879 unless ($form->submitted && $form->validate) { 884 880 print $form->render; 885 881 } else { 886 # do something with the entered data ... 887 # this is where your form processing code should go 882 # do something with the entered data 888 883 } 889 884 … … 935 930 =head1 LANGUAGE 936 931 932 # name field_size growable label hint type other default option_list validate 933 937 934 field_name[size]|descriptive label[hint]:type=default{option1[display string],...}//validate 938 935 … … 986 983 =item C<!field> 987 984 988 Include a named instance of a group defined with C<!group>.985 B<DEPRACATED> Include a named instance of a group defined with C<!group>. 989 986 990 987 =item C<!title> … … 1019 1016 =back 1020 1017 1021 =head2 Fields1018 =head2 Strings 1022 1019 1023 1020 First, a note about multiword strings in the fields. Anywhere where it says … … 1042 1039 unlabeled_field|'' 1043 1040 1044 Now, back to the beginning. Form fields are each described on a single line. 1045 The simplest field is just a name (which cannot contain any whitespace): 1041 =head2 Fields 1042 1043 Form fields are each described on a single line. The simplest field is 1044 just a name (which cannot contain any whitespace): 1046 1045 1047 1046 color 1048 1047 1049 1048 This yields a form with one text input field of the default size named `color'. 1050 The generated label for this field would be ``Color''. To add a longer or more \1049 The generated label for this field would be ``Color''. To add a longer or more 1051 1050 descriptive label, use: 1052 1051 … … 1100 1099 person*:text 1101 1100 1101 To create a C<radio> or C<select> field that includes an "other" option, 1102 append the string C<+other> to the field type: 1103 1104 position:select+other 1105 1106 Or, to let FormBuilder decide whether to use radio buttons or a dropdown: 1107 1108 position+other 1109 1110 Like growable fields, 'other' fields require FormBuilder 3.02 or higher. 1111 1102 1112 For the input types that can have options (C<select>, C<radio>, and 1103 1113 C<checkbox>), here's how you do it: … … 1213 1223 =head2 Language/Parser 1214 1224 1225 Deprecate the C<!field> directive 1226 1215 1227 Allow renaming of the submit button; allow renaming and inclusion of a 1216 1228 reset button -
trunk/lib/Text/FormBuilder/grammar
r73 r74 146 146 147 147 group_field: '!field' group_name name label(?) 148 { 148 { 149 warn "[Text::FormBuilder] The !field directive has been DEPRECATED (input file line $thisline). Please use the name:GROUP style"; 149 150 push @lines, [ 'group', { name => $item{name}, label => $item{'label(?)'}[0], group => $item{group_name} } ]; 150 151 } … … 154 155 field_group: name label(?) hint(?) group_type comment(?) 155 156 { 156 warn "[$thisline] comment = $item{'hint(?)'}[0]\n" if $item{'hint(?)'}[0];157 #warn "[$thisline] comment = $item{'hint(?)'}[0]\n" if $item{'hint(?)'}[0]; 157 158 #warn "[$thisline] field $item{name} is $item{group_type}\n"; 158 159 push @lines, [ 'group', {
Note: See TracChangeset
for help on using the changeset viewer.