示例#1
0
 /**
  * Adds an element to the form.
  *
  * @param WTK_Widget_Form_Element $element
  */
 public function add_element(WTK_Widget_Form_Element $element)
 {
     $this->elements[$element->get_name()] = $element;
     return $this;
 }
示例#2
0
文件: widget.php 项目: jcchavezs/WTK
 /**
  * Renders the string of HTML attributes for an element.
  *
  * @param  WTK_Widget_Form_Element $element The element whose attributes are being rendered
  * @return string
  */
 private function render_element_attributes(WTK_Widget_Form_Element $element)
 {
     $attributes = array();
     foreach ($element->get_attributes() as $key => $value) {
         switch (gettype($value)) {
             case 'string':
                 $attributes[] = $key . '="' . trim($value) . '"';
                 break;
             case 'boolean':
                 if ($value === true) {
                     $attributes[] = $key;
                 }
                 break;
             default:
                 $attributes[] = $key . "='" . json_encode($value) . "'";
                 break;
         }
     }
     return implode(' ', $attributes);
 }