PHP Classes

File: examples.php

Recommend this page to a friend!
  Classes of Ulisses Mantovani  >  PHP DB Form Creator  >  examples.php  >  Download  
File: examples.php
Role: Example script
Content type: text/plain
Description: Example of use
Class: PHP DB Form Creator
Generate HTML forms to edit database table records
Author: By
Last change: add config() method
Date: 7 years ago
Size: 2,867 bytes
 

Contents

Class file image Download
<?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');
*/
?>

For more information send a message to info at phpclasses dot org.