* @license LGPL, see license.txt for details * @link http://www.php-tools.net */ /** * Main examples prepend file, needed *only* for the examples framework! */ include_once 'patExampleGen/prepend.php'; $exampleGen->displayHead( 'Example' ); // EXAMPLE START ------------------------------------------------------ /** * main patForms class */ require_once $neededFiles['patForms']; /** * patErrorManager class */ require_once $neededFiles['patErrorManager']; /** * localisation stuff */ require_once $neededFiles['patI18n_configure']; // element definitions for this example $elementsDefinition = array( 'area' => array( 'type' => 'RadioGroup', 'attributes' => array( 'required' => 'yes', 'display' => 'yes', 'edit' => 'yes', 'label' => 'Area', 'description' => 'Choose the area to access here.', 'position' => '3', 'clicklabel' => 'yes', 'title' => 'Area', //'default' => 'a03', 'values' => array( array( 'label' => 'Very pretty area', 'value' => 'a01', ), array( 'label' => 'No-nonsense area', 'value' => 'a02', ), array( 'label' => 'Argh-area', 'value' => 'a03', ), ), ), ), ); // create the form $form =& patForms::createForm( $elementsDefinition, array( 'name' => 'myForm' ) ); // create the needed renderer. $renderer =& patForms::createRenderer( "Array" ); // set the renderer $form->setRenderer( $renderer ); // retrieve the element $group =& $form->getElementByName( 'area' ); // give the radio group the array renderer, that way we will be able // to decide where to place the underlying radio buttons ourselves. $group->setRenderer( $renderer ); // use auto-validation $form->setAutoValidate( 'save' ); // serialize the elements list( $element ) = $form->renderForm(); // ERROR DISPLAY ------------------------------------------------------ // ask the form if it has been submitted and display errors. For // convenience and also to keep the examples easy to understand, all // the following examples will use teh helper methods of the examples // framework to display the errors and the form. if( $form->isSubmitted() ) { displayErrors( $form ); // see patExampleGen/customFunctions.php } // DISPLAY FORM ------------------------------------------------------ // output the opening form tag echo $form->serializeStart(); // display the element. As we have rendered with the array renderer, // choosing where to place the radio group buttons is up to you. So // using normal non-template based output, this could look like this: ?>
$radio ) { echo ''; } ?>
'; echo $radio['element'].'
'; echo $radio['label'].'
'; echo '




'; echo $form->serializeEnd(); // EXAMPLE END ------------------------------------------------------ $exampleGen->displayFooter(); ?>