Tuesday, September 20, 2011

php-form-builder-class

Project Overview

The PFBC (PHP Form Builder Class) project is developed with the following goals in mind...

  • Promote rapid development of forms through an object-oriented PHP structure.
  • Eliminate the grunt/repetitive work of writing the html and validation when building forms.
  • Reduce human error by using a consistent/tested utility.

This project was first release to the open source community on April, 24 2009 at PHPClass.org. It was moved to its current location at Google's Project Hosting service on November 16, 2009. Since the initial release, the project has gone through over 20 version releases and is still under active development.

Version 2.x represents the first major rewrite in the project's history and attempts to evolve PFBC into a code base that is more efficient, easier to manage, and extensible.

System Requirements

Installation Instructions

Before writing any code, you'll first need to download the latest version of PFBC, extract the contents zip file, and upload the PFBC directory within the document root of your web server. NOTE: The phrase "within the document root" means that there must be a public path to the PFBC directory (e.g. http://www.mydomain.com/PFBC). The other files/directories outside of the PFBC folder that are included in the download are provided only for instruction and can be ommitted from your production environment. Once the PFBC directory is up on your web server, you're ready to get started creating your first form.

Examples/Tutorials

The links provided below are meant to demonstrate the key features included in the project. Currently, these links are using the pfbc2.0-php5 release. Each of these examples are also included in both of the project's download files seen above.

Code Samples

 <?php
//PFBC 2.x PHP 5 >= 5.3
session_start
();
include
($_SERVER["DOCUMENT_ROOT"] . "/PFBC/Form.php");
$form
= new PFBC\Form("GettingStarted", 300);
$form
->addElement(new PFBC\Element\Textbox("My Textbox:", "MyTextbox"));
$form
->addElement(new PFBC\Element\Select("My Select:", "MySelect", array(
   
"Option #1",
   
"Option #2",
   
"Option #3"
)));
$form
->addElement(new PFBC\Element\Button);
$form
->render();

//PFBC 2.x PHP 5
session_start
();
include
($_SERVER["DOCUMENT_ROOT"] . "/PFBC/Form.php");
$form
= new Form("GettingStarted", 300);
$form
->addElement(new Element_Textbox("My Textbox:", "MyTextbox"));
$form
->addElement(new Element_Select("My Select:", "MySelect", array(
   
"Option #1",
   
"Option #2",
   
"Option #3"
)));
$form
->addElement(new Element_Button);
$form
->render();
?>

No comments: