| 
<?php/*
 must be in "head" (or pior) section of the page; validations in javascript: $this->aFormulario['frmValidar']
 and "$oForm->pintaFormulario();" where the form will be ("body" section of the page)
 
 debe iniciarse en la seccion "head" (html) de la pagina o antes, para poder meter las validaciones ($this->aFormulario['frmValidar']) en esa seccion
 ejemplo de uso:
 */
 
 include_once("class.formulario.inc");
 
 //this array contains expecifications for the fields of the form
 $aCampos = array(
 //'id/name/ddbb_field' => array('properties' => 'type validation obligatory field_length', 'title' => 'Human readable Title: '),
 'titulo' => array('propiedades' => 'text - 1 100', 'titulo' => 'Título: '),
 'texto' => array('propiedades' => 'textarea - 0 16000000', 'titulo' => 'Texto: '),
 'fichero' => array('propiedades' => 'file', 'titulo' => 'Fichero: '),
 'tipo' => array('propiedades' => 'select', 'titulo' => 'Tipo: ', 'valores' => array('' => 'ninguno', '0' => 'cero', '1' => 'uno', '2' => 'dos', '3' => 'tres')),
 'activa' => array('propiedades' => 'checkbox', 'titulo' => 'Activa: ')
 );
 
 $oForm = form_sel('tabla'); //is possible too: $oForm = new formulario();
 $oForm->sRutaFicheros = 'img/'; //path to save uploaded files
 //$oForm->sQueryTabla = 'tabla_ej'; //table name for insertion/update/delete in a database
 //$oForm->sRowId = 'id'; //primary key name for update/delete records
 //$oForm->sRowIdVal = $sId; //primary key value of actual record
 $oForm->sAction = 'sample_form_procesing.php';
 
 $oForm->creaFormulario($aCampos); //internal construction of the form
 ?>
 <html>
 <head>
 <title>Sample form</title>
 <?php
 //"$sScriptsJS" contains javascript validations for the form, must echoed in the "head" section of the page
 //la variable "$sScriptsJS" debe pintarse en la cabecera de la pagina (<head>), con lo cual el formulario debe iniciarse y crearse antes
 $sScriptsJS = '<script type="text/javaScript" src="eventos.js"></script>'; //events functions for unobstrusive javascript
 $sScriptsJS .= '<script type="text/javaScript" src="class.formulario.js"></script>'; //javascript functions for validations
 $sScriptsJS .= $oForm->aFormulario['frmValidar']; //all the javascript code for validations of the form
 echo($sScriptsJS);
 ?>
 </head>
 <body>
 <?php
 $oForm->pintaFormulario(); //write the form, "echo"
 //echo($oForm->sError); //show errors
 ?>
 </body>
 </html>
 
 
 |