PHP Classes

PHP DB Form Creator: Generate HTML forms to edit database table records

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 389 All time: 6,659 This week: 206Up
Version License PHP version Categories
db-form-creation 1.4Artistic License5HTML, PHP 5, Databases, Tools


This class can generate HTML forms to edit database table records.

It can compose a HTML form for editing the values of each field of a record of a given database table.

The class can set the type of form input, label, options and HTML content to display before and after the form input.

The class can load the form inputs with database query results array with the values to initialize each form input.

The generated form HTML can be outputted or returned as a string.

Picture of Ulisses Mantovani
Name: Ulisses Mantovani <contact>
Classes: 2 packages by
Country: Brazil Brazil
Age: 35
All time rank: 3048221 in Brazil Brazil
Week rank: 286 Up14 in Brazil Brazil Up



$form = new Db_form();

/* Instance form (required)*/
// 1 mode
$form->setForm('<table result set array>');
// 2 mode
$form->setForm('<table name>', array('<field name>'=>'<label name>', ...) );

/* configuring render (optional)*/
// Filter fields
$form->setForm('<table result array>')->filter( array('<field name>', ... ) );

// Change field parameters | Change/Add Label text
$form->field('<field name>')->label('<label text>');

// Change field parameters | Change type (form library codeigniter)
$form->field('<field name>')->type('dropdown');

// Change field parameters | add options to field (for dropdown, radio, checkbox, etc)
$form->field('<field name>')->options( array('< value >'=>'< label >', ...) );

// Change field parameters | add html attributes
$form->field('<field name>')->attr( array('< attribute >'=>'< value >', ...) );

// Change field parameters | add default value for field (if checkbox add in Array)
$form->field('<field name>')->value( <value> );

// Change field parameters | add pre and after input content
$form->field('<field name>')->content( array('before'=>'< value >', 'after'=>'< value >') );

// Change field config parameters | change class parameter for only a unique field
$form->field('<field name>')->config( array('<config var>'=>'<new value >', ...') );

/* Configuring general bootstrap render output */
// Dynamic Change class parameters
$form->setConfig( array('
<config var>'=>'<new value>') );

// Stand alone change
$form-><config var> = '
<new value>';

/* IMPORTANT: see config vars in end of this Doc */

/* Fill form with result (optional)*/
// Get query
$qr = mysql_query( '
<row return>' );
$qr = mysql_fetch_array($qr);
// or Set array
$qr = array( '
<field name1>'=>'<value>', ... );

$form->fill( $qr );

/* Render form (required )*/
// For default print a array with block input | optional parameter print(true|false)
$rtn = $form->render( <auto print(true|false)> );

echo $rtn['
<field name>'];

/* Public config vars */
 $fieldset = true;
 $fieldset_name = '';
 $out_type = '
 $form_class = '
 $form_action = '';
 $parentt = true;
 $parent_tag = '
 $parent_class = '
 $label = true;
 $label_tag = '
 $label_class = '
col-md-3 control-label';
 $input_parent = true;
 $input_parent_tag = '
 $input_parent_class = '
 $input_class = '
 $input_check = array('
 $btn_submit = true;
 $btn_submit_config = array('
name'=>'btn_submit', 'class'=>'btn btn-success', 'value'=>'Gravar');
 $btn_apply = true;
 $btn_apply_config = array('
name'=>'btn_apply', 'class'=>'btn btn-info', 'value'=>'Aplicar');
 $submit_config = array('

  Files folder image Files  
File Role Description
Plain text file Db_class.php Class the class
Accessible without login Plain text file examples.php Example Example of use

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,659
This week:206Up