/** * Set bootstrap select element attributes.. * * @param ContextualConfig|Config $config The config. * @param Element $element The select element. * @param \Widget $widget The widget. * * @return void */ private function setStyledSelectAttributes($config, $element, $widget) { $element->addClass($config->get('form.styled-select.class')); $element->setAttribute('data-style', $config->get('form.styled-select.style')); $size = $config->get('form.styled-select.size'); if ($size !== 'auto') { $element->setAttribute('data-size', $size); } if ($widget->bootstrap_select_search || $this->hasExceededOptionsThreshold($config, $widget)) { $element->setAttribute('data-live-search', 'true'); } $format = $config->get('form.styled-select.selected-text-format'); if ($widget->multiple && $format) { $element->setAttribute('data-selected-text-format', html_entity_decode($format)); } // If a btn-* class isset, set it as data-style attribute. $classes = explode(' ', $widget->class); foreach ($classes as $class) { if (strpos($class, 'btn-') === 0) { $element->removeClass($class); $element->setAttribute('data-style', $class); break; } } }
/** * Set text area elements. * * @param \Widget $widget The form widget. * @param Element $element The widget element. * * @return void */ private function setTextareaAttributes($widget, Element $element) { if ($element->getTag() === 'textarea') { if ($widget->cols) { $element->setAttribute('cols', $widget->cols); } if ($widget->rows) { $element->setAttribute('rows', $widget->rows); } } }