Home  PHP Projekte  PHPDoc  Forms  Form (300k)  Flow Layout  API Docs  CVS - XML Demo I  CVS - XML Demo II  Demo: calendar  Demo: checkbox  Demo: calendar  Demo: combo  Demo: date  Demo: defaults  Demo: file  Demo: fileupload  Demo: hidden  Demo: image  Demo: password  Demo: radio  Demo: select  Demo: submit  Demo: tag  Demo: text  Demo: textarea  IT[X] Template  Userland Cache  Gtext  Menu 3  Columbo  PHP Schulung  Technik der Site  Büchertipps  Fotografie  Airbrush  Kontakt  Stuff 
|
OOH Form Rewrite - Flow Layout
The are errors in the form, it's invalid. This file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html> <head> <title>Form flow layout example</title> </head>
<body> <?php // whereever your source files reside... define(FORM_INCLUDE_DIR, "c:/www/apache/form/"); // include the loader include(FORM_INCLUDE_DIR . "form_loader.inc"); // include the core form files form_loader("flow_layout"); // include your form class include(FORM_INCLUDE_DIR . "example_flow_layout.inc"); include(FORM_INCLUDE_DIR . "integratedtemplate.inc"); include(FORM_INCLUDE_DIR . "integratedtemplateextension.inc"); // create form object $form = new example_bridge("c:/www/apache/form/", "form_elements_template.html"); $form->Init(); if ($form->isValid()) print "<hr>The form is valid.<hr>"; else print "<hr>The are errors in the form, it's invalid.<hr>";
print "<b>This file</b><p>"; highlight_string(preg_replace("@\t@", " ", implode("", file(FORM_INCLUDE_DIR . "flow_layout.php4")))); print "<p><hr><p>"; print "<b>Form definition</b><p>"; highlight_string(preg_replace("@\t@", " ", implode("", file(FORM_INCLUDE_DIR . "example_flow_layout.inc")))); print "<p><hr><p>"; print "<b>Custom form element date</b><p>"; highlight_string(preg_replace("@\t@", " ", implode("", file(FORM_INCLUDE_DIR . "form_element_custom_date.inc"))));
print "<p><hr><p>"; print "<b>Custom form element name</b><p>"; highlight_string(preg_replace("@\t@", " ", implode("", file(FORM_INCLUDE_DIR . "form_element_custom_name.inc")))); ?> </body> </html>
Form definition
<?php class example_bridge extends form_flow_layout { // define/build the form function Init() { $this->setDefaults( array ( "textsize" => 20, "textmaxlength" => 100) ); // make sure to escape special characters! $this->setJSError("Ooops some errors...\n\n", "\n\nPlease correct them..."); $this->startGroup("About you..."); $this->addElement( array( "name" => "firstname", "type" => "custom_name", "label" => "First name" ) );
$this->addElement( array( "name" => "surname", "type" => "custom_name", "label" => "Last name" ) ); $this->addBreak(); $this->addElement( array( "name" => "birthday", "type" => "custom_date", "label" => "Birthday" ) ); $this->endGroup(); $this->addBreak(); $this->startGroup("Preferred Icecream..."); $this->addElement( array( "name" => "icecream", "elname" => "ice_vanilla", "type" => "custom_radio", "checked" => true, "label" => "Vanilla", "value" => "Vanilla" ) ); $this->addBreak(); $this->addElement( array( "name" => "icecream", "elname" => "ice_choc", "type" => "custom_radio", "label" => "Chocolate", "value" => "Chocolate" ) );
$this->addBreak(); $this->addElement( array( "name" => "icecream", "elname" => "ice_straw", "type" => "custom_radio", "label" => "Strawberry", "value" => "Strawberry" ) ); $this->endGroup(); $this->startGroup("Preferred TV show..."); $this->addElement( array( "name" => "tvshow", "elname" => "tv_ses", "type" => "custom_radio", "label" => "Sessamestreet", "value" => "sessamestreet" ) ); $this->addBreak(); $this->addElement( array( "name" => "tvshow", "elname" => "tv_buff", "checked" => true, "type" => "custom_radio", "label" => "Buffy", "value" => "buffy" ) );
$this->addBreak(); $this->addElement( array( "name" => "tvshow", "elname" => "tv_news", "type" => "custom_radio", "label" => "NBC News", "value" => "NBC News" ) ); $this->endGroup(); $this->addBreak(); $this->addElement( array ( "name" => "submit", "type" => "custom_submit" ) ); $this->autoloadValues(); $this->Start("myform"); $this->printPage(); $this->Finish(); } // end func Init } // end class example_bridge ?>
Custom form element date
<?php /** * Custom date field, format: YmdHi. * * @author Ulf Wendel <ulf.wendel@phpdoc.de> * @version $Id: $ * @package Form * @access public */ class form_element_custom_date extends form_element_date {
var $optional_fields = array( "label" => "string" );
var $required_fields = array();
var $format = "YmdHi"; var $language = "en"; var $intro = "-%-"; var $intro_e = "Please select a date."; var $preload = true; var $now = "now"; var $label = "Date"; function get($subelement = "") {
$len = strlen($this->format); for ($i = 0; $i < $len; $i++) $html[$this->format{$i}] = form_element_date::get($this->format{$i}); $html = sprintf("%s%s%s %s:%s %s", $html["d"], $html["m"], $html["Y"], $html["H"], $html["i"], form_element_date::get("now") );
return array($html, $this->label, "Use the button 'now' to select the current date."); } // end func get
} // end class form_element_custom_date ?>
Custom form element name
<?php /** * Custom email input field * * @author Ulf Wendel <ulf.wendel@phpdoc.de> * @version $Id: $ * @access public * @package Form */ class form_element_custom_name extends form_element_text {
var $optional_fields = array ( "label" => "string" );
var $minlength = 3; var $maxlength = 40; var $length_e = "Please enter a name."; var $label = "Name"; function get($subelement = "") { if (true == $this->flag_frozen) return $this->getfrozen($subelement);
return array(form_element_text::get($subelement), $this->label, ""); } // end func get } // end class form_element_custom_name ?>
< ^ >
|