width: 540px; height: 200px; } .group { border: 2px solid #000; padding: 5px; } </style> </head> <body> <h1>Test de YuppForm</h1> <?php echo '<pre>'; print_r($_POST); print_r($_REQUEST); print_r($_GET); print_r($_FILES); echo '</pre>'; //$f = new YuppForm2( array('app'=>'blog', 'controller'=>'user', 'action'=>'login', 'isAjax'=>true) ); $f = new YuppForm2(array('actionUrl' => '#')); $group = new YuppFormField2Group("Rangos de edades"); $group->add(YuppForm2::check(array('name' => "rango1[]", 'value' => '0..10', 'label' => "0..10")))->add(YuppForm2::check(array('name' => "rango1[]", 'value' => '11..20', 'label' => "11..20")))->add(YuppForm2::check(array('name' => "rango1[]", 'value' => '21..30', 'label' => "21..30")))->add(YuppForm2::check(array('name' => "rango1[]", 'value' => '31..40', 'label' => "31..40"))); $f->add(YuppForm2::text(array('name' => "name", 'value' => 'carlos', 'label' => "Nombre")))->add(YuppForm2::text(array('name' => "email", 'value' => '*****@*****.**', 'label' => "Email")))->add(YuppForm2::password(array('name' => "pass", 'value' => 'abc123', 'label' => "Clave")))->add(YuppForm2::date(array('name' => "birthdate", 'value_year' => 1980, 'label' => "Fecha de nacimiento")))->add(YuppForm2::select(array("name" => "usertype", "value" => "ad", "label" => "Tipo", "options" => array('us' => 'usuario', 'ed' => 'editor', 'ad' => 'admin', 'pe' => 'pendiente'))))->add(YuppForm2::select(array("name" => "nombres[]", "value" => "m", "label" => "Nombres", "options" => array('p' => 'Pablo', 'm' => 'Miguel', 'a' => 'Andres', 'c' => 'Carlos'), "size" => 10, "multiple" => 'true')))->add(YuppForm2::radio(array('name' => "radio_btn_0", 'value' => 1, 'label' => "opcion 1")))->add(YuppForm2::radio(array('name' => "radio_btn_0", 'value' => 2, 'label' => "opcion 2")))->add(YuppForm2::radio(array('name' => "radio_btn_0", 'value' => 3, 'label' => "opcion 3")))->add($group)->add(YuppForm2::check(array('name' => "esMayor", 'value' => 'true', 'label' => "check 1")))->add(YuppForm2::text(array('name' => "company", 'value' => 'Sun Microsystems', 'label' => "Institucion")))->add(YuppForm2::text(array('name' => "position", 'value' => 'CEO', 'label' => "Cargo")))->add(YuppForm2::file(array('name' => "archivo1", 'label' => "Archivo")))->add(YuppForm2::submit(array('name' => "doit", 'label' => "Crear")))->add(YuppForm2::submit(array('action' => "list", 'label' => "Cancelar"))); //print_r( $f ); YuppFormDisplay2::displayForm($f); ?> </body> </html>
<?php $f = new YuppForm2(array("app" => "tests", "controller" => "helpersTest", "action" => "formTest", "method" => "get")); $f->add(YuppForm2::text(array('name' => "titulo", 'value' => $m->get('titulo'), 'label' => "Titulo")))->add(YuppForm2::bigtext(array('name' => "texto", 'value' => $m->get('texto'), 'label' => "Texto")))->add(YuppForm2::submit(array('name' => 'doit', 'label' => "Enviar")))->add(YuppForm2::submit(array('action' => 'index', 'label' => "Volver"))); YuppFormDisplay2::displayForm($f); ?> </div> <br/> Formulario ajax: <div style="width: 500px; padding:10px; padding-right:10px; background-color: #ffff80; border: 1px dashed #000"> <?php $f = new YuppForm2(array("app" => "tests", "controller" => "helpersTest", "action" => "formTest", "isAjax" => true, "ajaxBeforeSubmit" => "before_function", "ajaxCallback" => "after_function")); $f->add(YuppForm2::text(array('name' => "titulo", 'value' => $m->get('titulo'), 'label' => "Titulo")))->add(YuppForm2::bigtext(array('name' => "texto", 'value' => $m->get('texto'), 'label' => "Texto")))->add(YuppForm2::submit(array('name' => 'doit_ajax', 'label' => "Enviar")))->add(YuppForm2::submit(array('action' => 'index', 'label' => "Volver"))); YuppFormDisplay2::displayForm($f); ?> <div style="width: 95%; height: 25px; padding:10px; padding-right:10px; background-color: #8080ff; border: 1px dashed #000" id="content_div"></div> </div> <hr/> Este test muestra el uso del helper form, el cual sirve para generar formularios HTML mediante PHP.<br/> <ul> <li>El primer caso muestra un formulario comun que envia los datos usando el metodo GET de HTTP.</li> <li>El segundo caso muestra la funcionalidad del formulario AJAX que envia los datos del formulario y recibe informacion del servidor sin necesidad de recargar toda la pagina. Este caso es util para realizar busquedas y obtener resulados que se pueden mostrar sin tener que recargar toda la pagina, ahorrando tiempo.</li> </ul>