PHP Classes

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

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 390 All time: 6,657 This week: 64Up
Version License PHP version Categories
db-form-creation 1.4Artistic License5HTML, PHP 5, Databases, Tools
Description 

Author

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: 200 Up15 in Brazil Brazil Up

Example

<?php

include('db_form.php')
$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 = '
bootstrap';
 $form_class = '
form-horizontal';
 $form_action = '';
 $parentt = true;
 $parent_tag = '
div';
 $parent_class = '
form-group';
 $label = true;
 $label_tag = '
label';
 $label_class = '
col-md-3 control-label';
 $input_parent = true;
 $input_parent_tag = '
div';
 $input_parent_class = '
col-md-6';
 $input_class = '
form-control';
 $input_check = array('
checkbox'=>'');
 $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('
label_tag'=>'div');
*/
?>


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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:390
This week:0
All time:6,657
This week:64Up