Exemple #1
0
 public function wrapField($html, $attribute)
 {
     if ($this->model instanceof ITypeEnumerable && $attribute !== $this->model->tableSchema->primaryKey) {
         $classes = array('typeEnumerable');
         $hidden = true;
         foreach ($this->model->getTypesFields() as $type_id => $fields) {
             if (in_array($attribute, $fields)) {
                 $classes[] = 'typeEnumerable_' . $type_id;
                 if ($this->model->getType() && $this->model->getType()->id == $type_id) {
                     $hidden = false;
                 }
             }
         }
         $html = '<div name="' . $attribute . '" class="' . join(' ', $classes) . '" ' . ($hidden ? 'style="display:none" ' : '') . '>' . $html . '</div>';
     }
     return $html;
 }
Exemple #2
0
 public function renderWidget($widget)
 {
     ob_start();
     if ($widget instanceof TbSelect2 or $widget instanceof TbDatePicker or $widget instanceof TbTimePicker or $widget instanceof CJuiDateTimePicker) {
         echo $this->label($this->model, $widget->attribute, $widget->htmlOptions);
     }
     $widget->run();
     $html = ob_get_clean();
     if ($this->model instanceof ITypeEnumerable && $widget->attribute !== $this->model->tableSchema->primaryKey) {
         $classes = array('typeEnumerable');
         $hidden = true;
         foreach ($this->model->getTypesFields() as $type_id => $fields) {
             if (in_array($widget->attribute, $fields)) {
                 $classes[] = 'typeEnumerable_' . $type_id;
                 if ($this->model->getType() && $this->model->getType()->id == $type_id) {
                     $hidden = false;
                 }
             }
         }
         $html = '<div name="' . $widget->attribute . '" class="' . join(' ', $classes) . '" ' . ($hidden ? 'style="display:none" ' : '') . '>' . $html . '</div>';
     }
     return $html;
 }