$flexy->getElements() | $element->setValue() |
HTML_Template_Flexy | |
PEAR Manual | |
require_once 'HTML/Template/Flexy/Element.php'; |
new HTML_Template_Flexy_Element (
string $tag = ''
, array $attributes = NULL
)
Flexy uses a single lightweight class to represent All HTML Tags, All the variables of the class are public, and you are encouraged to use them. And the methods provide generic assignment and conversion abilities.
To force the toHtml() method to generate XHTML, rather than standard HTML, use $element->setAttributes(array('flexy:xhtml'=>true)); or add flexy:xhtml="true" to the attribute of the element in the template.
$tag - The name of the HTML Tag eg. img for <img ....
$attributes - Associative array of attributes, where key="value" is output when you turn it in toHtml(), If you need to represent a attribute without a value, use TRUE as the value. This also accepts a string in the format "href='/test.jpg' alt='test'", which will be parsed into the attributes array of the object.
The name of the html element eg. img for <img...
Attributes for the element
All the sub elements inside this, can be any object that implements toHtml(), or a string.
this value of thiswill be output when toHtml() is called, rather than the tags.
string or object that implements toHtml() method, and is returned by toHtml() before the tag HTML
string or object that implements toHtml() method, and is returned by toHtml() after the tag HTML
when you create an element, that is to be merged later with a full definition, you can assign the value here, and during toHtml(), the toValue() method will be called and select options, checkboxes and input values will be correctly filled in.
throws no exceptions thrown
This function can not be called statically.
Using an element to change a template.
|
template example
<body> <form name="xxxx"> <input name="test" length="12"> <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 /> <input name="test_radio" type="radio" xml:id="yes" value="yes" />yes<br /> <input name="test_radio" type="radio" xml:id="no" value="no" />no<br /> </form> </body> |
output from the Template
<body> <form name="xxxx"> ******<input name="test" length="12" class="bold" value="fred">!!!!!! <textarea name="test_textarea">blogs</textarea> <select name="test_select"> <option value="123">a selection option <option value="1234" selected>another selection option </select> <input name="test_checkbox" type="checkbox" value="1" checked="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" xml:id="yes" value="yes" checked>yes<br /> <input name="test_radio" type="radio" xml:id="no" value="no">no<br /> </form> </body> |
$flexy->getElements() | $element->setValue() |
HTML_Template_Flexy | |
PEAR Manual | |