Example #1
0
 public static function selectBox($value, $attrs, $table, $colums, $where = null, $order = null, $optAdd = null)
 {
     if (count($colums) >= 2) {
         $rows = NhucaudaotaoHelper::collect($table, $colums, $where, $order);
         if (is_array($attrs)) {
             $controlName = $attrs['name'];
             unset($attrs['name']);
             unset($attrs['value']);
             foreach ($attrs as $key => $val) {
                 if (is_array($val)) {
                     $controlAttrs .= " " . $key . '="' . implode(" ", $val) . '"';
                 } else {
                     $controlAttrs .= " " . $key . '="' . $val . '"';
                 }
             }
         } else {
             $controlAttrs = $attrs;
         }
         if (isset($attrs['hasEmpty']) && $attrs['hasEmpty'] == true) {
             $option = array("{$colums['0']}" => '', "{$colums['1']}" => '');
             array_unshift($rows, $option);
         }
         $optNull[] = JHTML::_('select.option', '', '', $colums[0], $colums[1]);
         if (is_array($optAdd)) {
             foreach ($optAdd as $key => $val) {
                 $optNull[] = JHtml::_('select.option', $key, $val, $colums[0], $colums[1]);
             }
         }
         return JHTML::_('select.genericlist', array_merge($optNull, $rows), @$controlName, @$controlAttrs, $colums[0], $colums[1], $value);
         //  return JHTML::_('select.genericlist',$options,$controlName, $controlAttrs, 'value','text',$value);
     }
     return '';
 }