Introduction

Introduction – A package for building HTML forms from DataObject classes

DB_DataObject_FormBuilder Description

DB_DataObject_FormBuilder will aid you in rapid application development using the packages DB_DataObject and HTML_QuickForm. For having a quick but working prototype of your application, simply model the database, run DataObject createTable script over it and write a script that passes one of the resulting objects to the FormBuilder class. The FormBuilder will automatically generate a simple but working HTML_QuickForm object that you can use to test your application. It also provides a processing method that will automatically detect if an insert() or update( )command has to be executed after the form has been submitted. If you have set up DataObject links.ini file correctly, it will also automatically detect if a table field is a foreign key and will populate a selectbox with the linked tables entries. There are many optional parameters that you can place in your DataObjects.ini or in the properties of your derived classes, that you can use to fine-tune the form-generation, gradually turning the prototypes into fully-featured forms, and you can take control at any stage of the process. Basic usage:

<?php
$do 
=& new MyDataObject();
// Insert "$do->get($some_id);" here to edit an 
// existing object instead of making a new one
$fg =& DB_DataObject_FormBuilder::create($do);
$form =& $fg->getForm();
if (
$form->validate()) {
    
$form->process(array(&$fg,'processForm'), false);
$form->freeze();
}
$form->display();
?>