Source for file example.php
Documentation is available at example.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>HTML_QuickForm_altselect - Example Usage</title>
require_once 'HTML/QuickForm.php';
// Include altselect.php after QuickForm, so that the plugin can be loaded
require_once 'HTML/QuickForm/altselect.php';
$form = & new HTML_QuickForm ('test_altselect');
// Add the altselect element, using the same arguments as you would a normal select element
$altselect = & $form->addElement ('altselect', 'test', 'Select a value:',
// Use the setMultiple() method, just as in HTML_QuickForm_select
// to turn the radio buttons into checkboxes
$altselect->setMultiple (true );
// Use setIncludeOther() to include the 'other' textfield for other possible values
$altselect->setIncludeOther (true );
// Use setSelected(), just as in HTML_QuickForm_select
// to set the default values
$altselect->setSelected ('b');
$form->addElement ('submit', 'submit', 'Submit');
// The exported value will either be a scalar or an array depending on what was posted,
// just as it would with HTML_QuickForm_select
$value = $form->exportValue ('test');
echo '<p>The result is: '. var_export($value, true ). '</p>';
Documentation generated on Mon, 11 Mar 2019 15:41:30 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|