<SELECT NAME="name"> -- creates PHP variable and code for select lists
Description
fills in the select values based on the form name and the tag name. If flexyignore is
used, it is left alone. If static is set, the currently defined options will be used.
And code added to check if the object variable matches them.
Example
Example 25-1. Setting variables for input // data object
class example_data {
var $theselect = 1;
function getOptions($what) {
switch ($what) {
case "theselect":
return array(
1 => 'One',
2 => 'Two'
);
default:
return array(
'-' => 'Error select not supported'
)
}
}
}
........
$this->theform = new example_data;
$this->theform->theselect = 1;
$this->theform->theselect_a = 'dogs';
$template->outputObject($this);
........ |
|
Example 25-2. Foreach in template <form name="theform">
<SELECT name="theselect">
<option>example</option>
</SELECT>
<SELECT name="theselect_a" static="TRUE">
<option>dogs</option>
<option>cats</option>
</SELECT>
</form> |
|
Example 25-3. Compiled template <FORM NAME="theform">
<SELECT NAME="theselect"><?php if (method_exists($t->theform,'getOptions'))
foreach($t->theform->getOptions('theselect') as $_k=>$_v) {
printf("<OPTION VALUE=\"%s\"%s>%s</OPTION>",
htmlspecialchars($_k),
($_k == $t->theform->theselect) ? ' SELECTED' : '',
htmlspecialchars($_v)
); } ?></SELECT>
<SELECT NAME="theselect_a" STATIC="TRUE">
<OPTION <? if ($t->theform->theselect_a == "dogs") echo ' SELECTED';?>>dogs</OPTION>
<OPTION <? if ($t->theform->theselect_a == "cats") echo ' SELECTED';?>>cats</OPTION>
</SELECT>
</FORM> |
|