コード例 #1
0
 /**
  * Return html rendering for the element label
  * $arr_return['label'] - array or string of form element lable 
  * $arr_return['html'] -  array or string of form element 
  *
  * @return  Array  $arr_return
  * 
  */
 function toHtml()
 {
     $arr_return = parent::toHtml();
     $arr_return['html'] = '';
     $arr_checkboxes = array();
     $arr_checkboxes = $this->getAttribute('checkboxes');
     $arr_checked = array();
     $arr_checked = $this->getAttribute('checked');
     $string = '';
     $id = $this->getAttribute('id');
     if (is_array($arr_checkboxes)) {
         foreach ($arr_checkboxes as $key => $value) {
             $encode_key = str_replace(' ', '_', $key);
             $string = '<input {attr_name=attr_value} {extra_attr} id="' . "{$id}_{$encode_key}" . '" value="' . $key . '" ';
             if (is_array($arr_checked)) {
                 $string .= in_array($key, $arr_checked) ? 'checked ' : '';
             }
             $string .= '%id|checked|checkboxes|separator% />';
             $string .= $value != '' ? '<label for="{attr_id}_' . $encode_key . '">' . $value . '</label>' : '';
             $string .= $this->arr_attr['separator'] . "\n";
             if ($this->return_type == 'string') {
                 $arr_return['html'] .= $string;
             } else {
                 $arr_return['html'][] = $string;
             }
         }
     }
     return $arr_return;
 }
コード例 #2
0
 /**
  * html  string for an element
  * Return html rendering for the element label
  * $arr_return['label'] - array or string of form element lable 
  * $arr_return['html'] -  array or string of form element 
  *
  * @return  Array  $arr_return
  * 
  */
 function toHtml()
 {
     $arr_return = parent::toHtml();
     $arr_return['html'] = "<select {attr_name=attr_value} {extra_attr} %type|selected|option%>\n";
     $arr_option = array();
     $arr_option = $this->arr_attr['option'];
     $selected = $this->arr_attr['selected'];
     foreach ($arr_option as $key => $value) {
         if ($key == $selected) {
             $arr_return['html'] .= '  <option value="' . $key . '" selected>' . $value . "</option>\n";
         } else {
             $arr_return['html'] .= '  <option value="' . $key . '">' . $value . "</option>\n";
         }
     }
     $arr_return['html'] .= "</select>\n";
     return $arr_return;
     //TODO: Add support for <optgroup label=""></optgroup>
 }
コード例 #3
0
 /**
  * html  string for an element
  * Return html rendering for the element label
  * $arr_return['label'] - array or string of form element lable 
  * $arr_return['html'] -  array or string of form element 
  *
  * @return  Array  $arr_return
  * 
  */
 function toHtml()
 {
     $arr_return = parent::toHtml();
     $arr_return['html'] = '';
     $arr_radios = array();
     $arr_radios = $this->getAttribute('radios');
     $checked = $this->getAttribute('checked');
     $id = $this->getAttribute('id');
     if (is_array($arr_radios)) {
         foreach ($arr_radios as $key => $value) {
             $encode_key = str_replace(' ', '_', $key);
             $arr_return['html'] .= '<input {attr_name=attr_value} {extra_attr} id="' . "{$id}_{$encode_key}" . '" value="' . $key . '"';
             $arr_return['html'] .= $key == $checked ? ' checked' : '';
             $arr_return['html'] .= '%id|checked|radios|separator% />';
             $arr_return['html'] .= $value != '' ? '<label for="{attr_id}_' . $encode_key . '">' . $value . '</label>' : '';
             $arr_return['html'] .= $this->arr_attr['separator'] . "\n";
         }
     }
     return $arr_return;
 }