예제 #1
0
 public function drawHtml($tag, $id)
 {
     if (method_exists('htmlGmp', $this->html)) {
         $method = $this->html;
         //echo $this->name. ': '. $this->value. '<br />';
         if (!empty($this->value)) {
             $this->htmlParams['value'] = $this->value;
         }
         if ($method == 'checkbox') {
             if ($this->value == 1) {
                 $this->htmlParams['checked'] = 1;
             }
         }
         if ($this->adapt['html']) {
             fieldAdapterGmp::_($this, $this->adapt['html'], fieldAdapterGmp::HTML);
         }
         $params = $this->processParams($tag, $id);
         if ($params != '') {
             return $params;
         }
         if ($this->name == 'default_value') {
             $optionsFromDb = frameGmp::_()->getModule('optionsGmp')->getHelper()->getOptions($id);
             if (!empty($optionsFromDb)) {
                 $options = array(0 => __('Select', GMP_LANG_CODE));
                 foreach ($optionsFromDb as $k => $v) {
                     $options[$k] = $v;
                 }
                 $method = 'selectbox';
                 $this->htmlParams['optionsGmp'] = $options;
             }
         }
         $htmlContent = htmlGmp::$method($this->name, $this->htmlParams);
         if (!empty($this->errorEl)) {
             if (is_bool($this->errorEl)) {
                 $errorEl = '<div class="toeErrorForField toe_' . htmlGmp::nameToClassId($this->name) . '"></div>';
             } else {
                 //if it is string
                 $errorEl = $this->errorEl;
             }
             $htmlContent .= $errorEl;
         }
         return $htmlContent;
     }
     return false;
 }