예제 #1
0
 /**
  * render_field hook
  * @param  cs_form $form form object
  * @return string        the element html
  */
 public function render_field(cs_form $form)
 {
     $id = $this->get_html_id();
     $attributes = $this->get_attributes();
     $this->tag = 'div';
     $output = "<{$this->tag} id=\"{$id}\"{$attributes}>\n";
     $required = $this->validate->has_value('required') ? '<span class="required">*</span>' : '';
     $requiredafter = $requiredbefore = $required;
     if ($this->required_position == 'before') {
         $requiredafter = '';
         $requiredbefore = $requiredbefore . ' ';
     } else {
         $requiredbefore = '';
         $requiredafter = ' ' . $requiredafter;
     }
     if (!empty($this->title)) {
         if ($this->tooltip == FALSE) {
             $this->label_class .= " " . preg_replace("/cs_/i", "label-", get_class($this));
             $this->label_class = trim($this->label_class);
             $label_class = !empty($this->label_class) ? " class=\"{$this->label_class}\"" : "";
             $output .= "<label for=\"{$id}\"{$label_class}>{$requiredbefore}" . $this->get_text($this->title) . "{$requiredafter}</label>\n";
         } else {
             if (!in_array('title', array_keys($this->attributes))) {
                 $this->attributes['title'] = strip_tags($this->get_text($this->title) . $required);
             }
             $id = $this->get_html_id();
             $form->add_js("\$('#{$id}','#{$form->get_id()}').tooltip();");
         }
     }
     $output .= $this->latitude->render($form);
     $output .= $this->longitude->render($form);
     $output .= "</{$this->tag}>\n";
     return $output;
 }