DB_DataObject_FormBuilder
[ class tree: DB_DataObject_FormBuilder ] [ index: DB_DataObject_FormBuilder ] [ all elements ]

File: FormBuilder.php

Source Location: /DB_DataObject_FormBuilder-1.0.2/DB/DataObject/FormBuilder.php

Classes:

DB_DataObject_FormBuilder
This is the main class for FormBuilder. It does most of the real work.

Page Details:

This package helps with type and foreign key aware rapid development of forms as well as many options to allow the advanced features to be used in a production environment.

All the settings for FormBuilder must be in a section [DB_DataObject_FormBuilder] within the DataObject.ini file (or however you've named it). If you stuck to the DB_DataObject example in the doc, you'll read in your config like this:

  1.   $config parse_ini_file('DataObject.ini'true);
  2.   foreach ($config as $class => $values{
  3.       $options &PEAR::getStaticProperty($class'options');
  4.       $options $values;
  5.   }
Now you're ready to go!

You can also set any option through your DB_DataObject derived classes by prepending 'fb_' to the option name. Ex: 'fb_fieldLabels'. This is the preferred way of setting DataObject-specific options.

You may also set all options manually by setting them in the DO ir FB objects.

You may also set the options in an FB derived class, but this isn't as well supported.

In addition, there are special methods you can define in your DataObject classes for even more control.

  • preGenerateForm(&$formBuilder): This method will be called before the form is generated. Use this to change property values or options in your DataObject. This is the normal plave to set up fb_preDefElements. Note: the $formBuilder object passed in has not yet copied the options from the DataObject into it. If you plan to use the functions in FB in this method, call populateOptions() on it first.
  • postGenerateForm(&$form, &$formBuilder): This method will be called after the form is generated. The form is passed in by reference so you can alter it. Use this method to add, remove, or alter elements in the form or the form itself.
  • preProcessForm(&$values, &$formBuilder): This method is called just before FormBuilder processes the submitted form data. The values are sent by reference in the first parameter as an associative array. The key is the element name and the value the submitted value. You can alter the values as you see fit (md5 on passwords, for example).
  • postProcessForm(&$values, &$formBuilder): This method is called just after FormBuilder processed the submitted form data. The values are again sent by reference. This method could be used to inform the user of changes, alter the DataObject, etc.
  • getForm($action, $target, $formName, $method, &$formBuilder): If this function exists, it will be used instead of FormBuilder's internal form generation routines Use this only if you want to create the entire form on your own.

Note for PHP5-users: These properties have to be public! In general, you can override all settings from the .ini file by setting similarly-named properties in your DataObject classes.

Most basic usage:

  1.   $do =new MyDataObject();
  2.   // Insert "$do->get($some_id);" here to edit an existing object instead of making a new one
  3.   $fg =DB_DataObject_FormBuilder::create($do);
  4.   $form =$fg->getForm();
  5.   if ($form->validate()) {
  6.       $form->process(array(&$fg,'processForm')false);
  7.       $form->freeze();
  8.   }
  9.   $form->display();

For more information on how to use the DB_DataObject or HTML_QuickForm packages themselves, please see the excellent documentation on http://pear.php.net/.

PHP versions 4 and 5

Includes:

require_once('DB/DataObject.php') [line 92]

DB_DATAOBJECT_FORMBUILDER_CROSSLINK [line 101]

DB_DATAOBJECT_FORMBUILDER_CROSSLINK = 1048576

[ Top ]



DB_DATAOBJECT_FORMBUILDER_ENUM [line 103]

DB_DATAOBJECT_FORMBUILDER_ENUM = 4194304

[ Top ]



DB_DATAOBJECT_FORMBUILDER_ERROR_NODATAOBJECT [line 109]

DB_DATAOBJECT_FORMBUILDER_ERROR_NODATAOBJECT = 4712

[ Top ]



DB_DATAOBJECT_FORMBUILDER_ERROR_UNKNOWNDRIVER [line 108]

DB_DATAOBJECT_FORMBUILDER_ERROR_UNKNOWNDRIVER = 4711

[ Top ]



DB_DATAOBJECT_FORMBUILDER_GROUP [line 105]

DB_DATAOBJECT_FORMBUILDER_GROUP = 16777216

[ Top ]



DB_DATAOBJECT_FORMBUILDER_QUERY_AUTODETECT [line 95]

DB_DATAOBJECT_FORMBUILDER_QUERY_AUTODETECT = 0

[ Top ]



DB_DATAOBJECT_FORMBUILDER_QUERY_FORCEINSERT [line 96]

DB_DATAOBJECT_FORMBUILDER_QUERY_FORCEINSERT = 1

[ Top ]



DB_DATAOBJECT_FORMBUILDER_QUERY_FORCENOACTION [line 98]

DB_DATAOBJECT_FORMBUILDER_QUERY_FORCENOACTION = 3

[ Top ]



DB_DATAOBJECT_FORMBUILDER_QUERY_FORCEUPDATE [line 97]

DB_DATAOBJECT_FORMBUILDER_QUERY_FORCEUPDATE = 2

[ Top ]



DB_DATAOBJECT_FORMBUILDER_REVERSELINK [line 104]

DB_DATAOBJECT_FORMBUILDER_REVERSELINK = 8388608

[ Top ]



DB_DATAOBJECT_FORMBUILDER_TRIPLELINK [line 102]

DB_DATAOBJECT_FORMBUILDER_TRIPLELINK = 2097152

[ Top ]



Documentation generated on Mon, 09 Apr 2012 19:00:03 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.