Example #1
0
 /**
  * Visit select element.
  *
  * @param T_Form_Select $node  select node.
  */
 function visitFormSelect(T_Form_Select $node)
 {
     $attributes = $node->getAllAttributes();
     $attributes += array('name' => $node->getFieldname(), 'id' => $this->getNodeId($node));
     $xhtml = $this->createLabel($node);
     // create <select>
     $xhtml .= $this->preElement($node);
     $xhtml .= $this->indent . '<select ';
     foreach ($attributes as $key => $value) {
         $xhtml .= $key . '="' . $this->escape($value) . '"' . EOL . $this->indent . '       ';
     }
     $xhtml = rtrim($xhtml) . ' >' . EOL;
     $this->changeIndent(1);
     // render the option list
     $options = $node->getOptions();
     $default = $node->getDefault();
     foreach ($options as $value => $label) {
         $xhtml .= $this->indent . '<option value="' . $this->escape($value) . '"';
         if (strcmp($value, $default) === 0) {
             $xhtml .= ' selected="selected"';
         }
         $xhtml .= '>' . $this->escape($label) . '</option>' . EOL;
     }
     // close <select>
     $this->changeIndent(-1);
     $xhtml .= $this->indent . '</select>' . EOL;
     $xhtml .= $this->postElement($node);
     $this->addXhtml($xhtml);
 }