<FORM NAME="name"
<FORM NAME="name" – configures automatic form elements
Synopsis
Usage (
<FORM NAME="name">
)
Description
By default, all forms are converted to HTML_Template_Flexy_Elements, so they can be altered at runtime.
Example
Using an element to change a template.
<?php
$form = new HTML_Template_Flexy();
$form->compile('some_file_name');
// create an instance (note you dont have to specify any details..)
$elements['theform'] = new HTML_Template_Flexy_Element;
// change an attribute
$elements['theform']->attributes['action'] = 'http://pear.php.net';
//
// for the different types of elements:
$elements['test_textarea'] = new HTML_Template_Flexy_Element;
$elements['test_textarea']->setValue('Blogs');
// select options
$elements['test_select'] = new HTML_Template_Flexy_Element;
$elements['test_select']->setOptions( array(
'123' => 'a select option',
'1234' => 'another select option'
));
$elements['test_select']->setValue('1234');
// checkboxes
$elements['test_checkbox'] = new HTML_Template_Flexy_Element;
$elements['test_checkbox']->setValue(1);
// array type checkboxes..
$elements['test_checkbox_array[]'] = new HTML_Template_Flexy_Element;
$elements['test_checkbox_array[]']->setValue(array(1,2));
// radio buttons
$val = 'yes';
$elements['test_radio'] = new HTML_Template_Flexy_Element;
// if you have a default - you may want default to using it..
$elements['test_radio']->setValue($val != 'no' ? $val : 'no');
$form->outputObject(new StdClass, $elements);
// in the example below, the new data you have added is to the existing attributes
?>
template example
<BODY> <FORM name="theform"> <TEXTAREA name="test_textarea"></TEXTAREA> <SELECT name="test_select"></SELECT> <input name="test_checkbox" type="checkbox" value="1"> <input name="test_checkbox_array[]" type="checkbox" value="1">1<BR> <input name="test_checkbox_array[]" type="checkbox" value="2">2<BR> <input name="test_checkbox_array[]" type="checkbox" value="3">3<BR> <!-- you need to use id's --> <input name="test_radio" type="radio" id="radio_yes" value="yes">yes<BR> <input name="test_radio" type="radio" id="radio_no" value="no">no<BR> </FORM> </BODY>
output from the Template
<BODY> <FORM name="theform" action="http://pear.php.net"> <TEXTAREA name="test_textarea">Blogs</TEXTAREA> <SELECT name="test_select"> <option value="123">a selection option</option> <option value="1234" selected>another selection option</option> </SELECT> <input name="test_checkbox" type="checkbox" value="1" checked> <input name="test_checkbox_array[]" type="checkbox" value="1" checked>1<BR> <input name="test_checkbox_array[]" type="checkbox" value="2" checked>2<BR> <input name="test_checkbox_array[]" type="checkbox" value="3">3<BR> <input name="test_radio" type="radio" value="yes" id="radio_yes" checked>yes<BR> <input name="test_radio" type="radio" value="no" id="radio_no">no<BR> </FORM> </BODY>