/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/examples/form2.php
ViewVC logotype

Annotation of /nfo/php/libs/com.newsblob.phphtmllib/examples/form2.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Sat Sep 20 00:20:55 2003 UTC (20 years, 10 months ago) by jonen
Branch: MAIN
Changes since 1.1: +20 -2 lines
+ updated whole phphtmllib to v2.3.0

1 jonen 1.1 <?php
2    
3     /**
4     * This example illustrates the use of the
5     * NavTable widget.
6     *
7     *
8 jonen 1.2 * $Id: form2.php,v 1.8 2003/08/01 01:32:40 hemna Exp $
9 jonen 1.1 *
10     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
11     * @package phpHtmlLib
12     * @subpackage form-examples
13     * @version 2.2.0
14     *
15     */
16    
17     /**
18     * Include the phphtmllib libraries
19     *
20     */
21     include("includes.inc");
22    
23     /**
24     * Include the Form Processing objects
25     *
26     */
27     include_once($phphtmllib."/form/includes.inc");
28    
29    
30     //use the class we defined from
31     //Example 3.
32     include_once("MyLayoutPage.inc");
33    
34     /**
35     * A simple Page Layout object child.
36     * this came from Example 3.
37     *
38     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
39     * @package phpHtmlLib
40     * @subpackage form-examples
41     */
42     class Form2Page extends MyLayoutPage {
43    
44     function content_block() {
45     //build the FormProcessor, and add the
46     //Form content object that the FormProcessor
47     //will use.
48     //
49     //This uses the StandardFormContent object to build
50     //and render the look/feel of the form. It has a built
51     //in mechanism for doing the form submit buttons, including
52     //the Cancel action.
53     //The title of this form is 'Testing'.
54     //the cancel url to go to is http://www.newsblob.com
55     //and the width of the form is 600
56     return new FormProcessor( new StandardAccountForm("Testing",
57     "http://www.newsblob.com",
58     600));
59     }
60     }
61    
62     /**
63     * A simple Page Layout object child.
64     * this came from Example 3.
65     *
66     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
67     * @package phpHtmlLib
68     * @subpackage form-examples
69     */
70     class StandardAccountForm extends StandardFormContent {
71    
72     /**
73     * This method gets called EVERY time the object is
74     * created
75     */
76     function form_init_elements() {
77     $this->add_element( new FEText("First Name", TRUE, 20) );
78    
79     $password = new FEPassword("Password", TRUE);
80     $this->add_element( $password );
81    
82     $confirm = new FEConfirmPassword("Confirm Password", TRUE);
83     $confirm->password( $password );
84     $this->add_element( $confirm );
85    
86     $this->add_element( new FEEmail("Email Address", TRUE, "200px") );
87    
88     //This will build a scrollable list of checkboxes.
89     $this->add_element( new FECheckBoxList("List", FALSE,
90     "200px", "80px",
91     array("Testing 123" => "foo",
92     "What is this?" => "bar",
93     "Somone's test" => "blah",
94     "Slerm" => "slerm",
95     "Flem" => "flom",
96     "One" => 1)));
97    
98 jonen 1.2 $this->add_element( new FEListBox("Anrede", FALSE, "100px", NULL,array("Frau"=>0,"Herr"=>1)) );
99    
100 jonen 1.1 //build a large textarea
101 jonen 1.2 $this->add_element( new FETextArea("Comment", TRUE, 20, 10,"400px", "100px" ) );
102 jonen 1.1
103     $this->add_hidden_element( "foo" );
104 jonen 1.2
105     $this->add_element( new FECheckBox ("Patient Contact1", "Daytime Phone") );
106     $this->add_element( new FECheckBox ("Patient Contact2", "Evening Phone") );
107     $this->add_element( new FECheckBox ("Patient Contact3", "Email") );
108    
109 jonen 1.1 }
110    
111     /**
112     * This method is called only the first time the form
113     * page is hit.
114     */
115     function form_init_data() {
116     //Pull some valies from the DB
117     //and set the initial values of some of the
118     //form fields.
119     //
120     //In this example we just hard code some
121     //initial values
122     $this->set_element_value("First Name", "testing");
123    
124     //set a few of the checkboxlist items as checked.
125     $this->set_element_value("List", array("bar","slerm",1));
126    
127     //change the value of the hidden form field
128     $this->set_hidden_element_value("foo", "hemna");
129     }
130    
131     /**
132     * This method is called by the StandardFormContent object
133     * to allow you to build the 'blocks' of fields you want to
134     * display. Each form block will live inside a fieldset tag
135     * with the a title.
136     *
137     * In this example we have 2 form 'blocks'.
138     */
139     function form_content() {
140     $this->add_form_block("User Info", $this->_user_info() );
141     $this->add_form_block("Optional", $this->_optional_info() );
142     }
143    
144     /**
145     * This private method builds the table that holds
146     * the 'user' form fields'
147     *
148     */
149     function &_user_info() {
150     $table = &html_table($this->_width,0,2);
151     $table->add_row($this->element_label("First Name"),
152     $this->element_form("First Name"));
153    
154     $table->add_row($this->element_label("Email Address"),
155     $this->element_form("Email Address"));
156    
157     $table->add_row($this->element_label("Password"),
158     $this->element_form("Password"));
159    
160     $table->add_row($this->element_label("Confirm Password"),
161     $this->element_form("Confirm Password"));
162    
163     return $table;
164     }
165    
166     /**
167     * This private method builds the table that holds
168     * the 'optional' form fields'
169     *
170     */
171     function &_optional_info() {
172     $table = &html_table($this->_width,0,2);
173    
174 jonen 1.2 $table->add_row($this->element_label("Anrede"),
175     $this->element_form("Anrede"));
176    
177 jonen 1.1 $table->add_row($this->element_label("List"),
178     $this->element_form("List"));
179    
180     $table->add_row($this->element_label("Comment"),
181     $this->element_form("Comment"));
182    
183 jonen 1.2 $td = new TDtag( array("colspan" => 2),
184     $this->element_form("Patient Contact1"),
185     $this->element_form("Patient Contact2"),
186     $this->element_form("Patient Contact3") );
187    
188     $table->add_row( $td );
189    
190 jonen 1.1 return $table;
191     }
192    
193     /**
194     * This method gets called after the FormElement data has
195     * passed the validation, and has been confirmed. This
196     * enables you to validate the data against some backend
197     * mechanism, say a DB.
198     *
199     */
200     function form_backend_validation() {
201 jonen 1.2 //var_dump( $this->has_confirm() );
202 jonen 1.1 //HARD CODE an error here to show how to show an error
203     //and that it will prevent the confirm_action() method
204     //from being called
205     $this->add_error("First Name", "Duplicate!! You suck!");
206     return FALSE;
207     }
208    
209     /**
210     * This method will get called after all validation has
211     * passed, and the confirmation has been accepted.
212     *
213     * This is where u save the info to the DB.
214     */
215     function confirm_action() {
216     //$this->set_action_message("WOO!");
217     return TRUE;
218     }
219     }
220    
221    
222     $page = new Form2Page("Form Example 2");
223     print $page->render();
224     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed