示例#1
0
 public function preRender() : string
 {
     if (count($this->children) > 0) {
         foreach ($this->children as $child) {
             $child->setSelected($child->get('value') == $this->value);
         }
     }
     if (is_null($this->data) === false) {
         foreach ($this->data as $option) {
             $value = '';
             $label = '';
             if (isset($option['label']) === true) {
                 $value = $option['value'];
                 $label = $option['label'];
             } elseif (isset($option[1]) === true) {
                 $value = $option[0];
                 $label = $option[1];
             }
             settype($this->value, 'string');
             settype($value, 'string');
             $this->add($this->build('option', $value, $label, $this->value == $value));
         }
     }
     return parent::preRender();
 }
示例#2
0
文件: nav.php 项目: dev-lucid/html
 public function preRender()
 {
     $is_tabs = $this->getTabs();
     $active_index = false;
     for ($i = 0; $i < count($this->children); $i++) {
         if ($this->children[$i]->href == $this->active_target) {
             $this->children[$i]->active(true);
         }
         if ($is_tabs === true) {
             $this->children[$i]->attributes['data-toggle'] = 'tab';
             $this->children[$i]->attributes['role'] = 'tab';
             if ($this->children[$i]->active() === true) {
                 $active_index = $i;
                 $this->panes[$i]->active(true);
             }
         }
         $this->children[$i]->preHtml = '<li class="nav-item">' . $this->children[$i]->preHtml;
         $this->children[$i]->postHtml = $this->children[$i]->postHtml . '</li>';
     }
     if ($is_tabs === true && $active_index === false && count($this->children) > 0) {
         $this->children[0]->active(true);
         $this->panes[0]->active(true);
         $this->active_target = $this->children[0]->href;
     }
     return parent::preRender();
 }
示例#3
0
 public function preRender() : string
 {
     if ($this->useCheckableLayout === true) {
         $this->addClass('form-group');
         $this->preChildrenHtml .= '<div class="' . $this->checkableLayoutClass . '">';
         $this->postChildrenHtml = '</div>' . $this->postChildrenHtml;
         if ($this->useRowLayout === true) {
             $this->addClass('row');
             $this->groupLabel->addClass('col-' . $this->gridSizeMinimum . '-' . $this->gridSizeLabel);
             $this->groupLabel->addClass('col-form-label');
             $this->preChildrenHtml .= '<div class="col-' . $this->gridSizeMinimum . '-' . $this->gridSizeField . '">';
             $this->postChildrenHtml = '</div>' . $this->postChildrenHtml;
             foreach ($this->children as $child) {
                 $child->preHtml = '<div class="form-check"><label class="form-check-label">' . $child->preHtml;
                 $child->postHtml .= '</label></div>';
             }
         } else {
             foreach ($this->children as $child) {
                 $child->preHtml .= '<label>';
                 $child->postHtml = '</label>' . $child->postHtml;
             }
         }
     } else {
         $this->addClass('form-group');
         if ($this->useRowLayout === true) {
             $this->addClass('row');
             if (is_object($this->groupLabel) === true) {
                 $this->groupLabel->addClass('col-' . $this->gridSizeMinimum . '-' . $this->gridSizeLabel);
                 $this->groupLabel->addClass('col-form-label');
             }
             $first = true;
             foreach ($this->children as $child) {
                 if ($first === true) {
                     $child->preHtml .= '<div class="col-' . $this->gridSizeMinimum . '-' . $this->gridSizeField . '">';
                     $first = false;
                 } else {
                     $child->preHtml .= '<div class="col-' . $this->gridSizeMinimum . '-' . $this->gridSizeField . ' col-offset-' . $this->gridSizeMinimum . '-' . $this->gridSizeLabel . '">';
                 }
                 $child->postHtml = '</div>' . $child->postHtml;
             }
         } else {
             # nothing to do in this case!
         }
     }
     if (is_null($this->groupLabel) === false) {
         $this->preChildrenHtml = $this->groupLabel->render() . $this->preChildrenHtml;
     }
     return parent::preRender();
 }