Example #1
0
 protected function renderItems($items, $options = [])
 {
     $lines = [];
     foreach ($items as $i => $item) {
         if (isset($item['visible']) && !$item['visible']) {
             continue;
         }
         if (is_string($item)) {
             $lines[] = $item;
             continue;
         }
         if (!array_key_exists('label', $item)) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
         $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
         $itemOptions = ArrayHelper::getValue($item, 'options', []);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $url = array_key_exists('url', $item) ? $item['url'] : null;
         if ($url === null) {
             $content = $label;
         } else {
             $content = Html::a($label, $url, $linkOptions);
         }
         $lines[] = Html::tag('li', $content, $itemOptions);
     }
     return Html::tag('ul', implode("\n", $lines), $options);
 }
Example #2
0
 public function run()
 {
     $this->registerPlugin('material_select');
     if ($this->hasModel()) {
         return Html::activeDropDownList($this->model, $this->attribute, $this->data, $this->options);
     } else {
         return Html::dropDownList($this->name, $this->value, $this->data, $this->options);
     }
 }
Example #3
0
 public function run()
 {
     if (!isset($this->clientOptions['container'])) {
         $this->clientOptions['container'] = 'body';
     }
     $this->registerPlugin('pickadate');
     Html::addCssClass($this->options, 'datepicker');
     if ($this->hasModel()) {
         $this->options['data-value'] = isset($this->value) ? $this->value : Html::getAttributeValue($this->model, $this->attribute);
         return Html::activeInput('date', $this->model, $this->attribute, $this->options);
     } else {
         $this->options['data-value'] = $this->value;
         return Html::input('date', $this->name, $this->value, $this->options);
     }
 }
Example #4
0
 /**
  * Initializes the widget options.
  * This method sets the default values for various options.
  */
 protected function initOptions()
 {
     if ($this->modalType !== null) {
         Html::addCssClass($this->options, $this->modalType);
     }
     Html::addCssClass($this->options, 'modal');
     if ($this->clientOptions !== false) {
         $this->clientOptions = array_merge(['show' => false], $this->clientOptions);
     }
     if ($this->closeButton !== false) {
         Html::addCssClass($this->closeButton, 'modal-close');
     }
     if ($this->toggleButton !== false) {
         Html::addCssClass($this->toggleButton, 'modal-trigger');
         if (!isset($this->toggleButton['data-target']) && !isset($this->toggleButton['href'])) {
             $this->toggleButton['data-target'] = $this->options['id'];
         }
     }
 }
Example #5
0
 /**
  * @inheritDoc
  */
 public function radioList($items, $options = [])
 {
     $this->parts['{label}'] = '';
     if (!isset($options['separator'])) {
         $options['separator'] = Html::tag('br');
     }
     $this->parts['{input}'] = \talview\materialize\Html::activeRadioList($this->model, $this->attribute, $items, $options);
     return $this;
 }
Example #6
0
 protected function renderBody($items)
 {
     $ret = '';
     foreach ($items as $i => $item) {
         $item['options']['class'] = isset($item['options']['class']) ? $item['options']['class'] . ' col s12' : 'col s12';
         $ret .= Html::tag('div', $item['content'], $item['options']);
     }
     return $ret;
 }
Example #7
0
 protected function renderCardContent($data)
 {
     foreach ($data as $content) {
         if (isset($content['activator'])) {
             Html::addCssClass($content['options'], 'card-title');
             Html::addCssClass($content['options'], 'activator');
         }
         $contents[] = Html::tag(isset($content['tag']) ? $content['tag'] : 'span', $content['body'], isset($content['options']) ? $content['options'] : []);
     }
     return implode("\n", $contents);
 }