예제 #1
0
 /**
  * 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;
         }
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function extractConfig($key, Config $config, BootstrapConfigModel $model)
 {
     if ($config->has($key)) {
         $config = $config->get($key);
         $keys = explode('.', $key);
         $model->name = end($keys);
         $model->icons_template = $config['template'];
         $model->icons_paths = implode("\n", (array) $config['paths']);
         $model->icons_path = $config['path'];
         $model->icons_source = 'paths';
     }
 }
예제 #3
0
 /**
  * Get existing names of multiple config types..
  *
  * @param string $typeName Tye name of a multiple type.
  *
  * @return array
  */
 public function getExistingNames($typeName)
 {
     $type = $this->getType($typeName);
     $this->guardMultipleType($typeName, $type);
     $config = (array) $this->config->get($type->getPath());
     return array_keys($config);
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function extractConfig($key, Config $config, BootstrapConfigModel $model)
 {
     $keys = explode('.', $key);
     $model->name = end($keys);
     $model->form_widget_control = $config->get($key . '.form-control', true);
     $model->form_widget_modal_footer = $config->get($key . '.modal-footer', false);
     $model->form_widget_input_group = $config->get($key . '.input-group', false);
     $model->form_widget_styled_select = $config->get($key . '.styled-select', false);
     $model->form_widget_label = $config->get($key . '.label', true);
 }
예제 #5
0
 /**
  * Load deprecated global config.
  *
  * @param Config $config Bootstrap config.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 private function loadConfigFromGlobals(Config $config)
 {
     // support deprecated config
     if (isset($GLOBALS['BOOTSTRAP'])) {
         $config->merge($GLOBALS['BOOTSTRAP']);
     }
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function extractConfig($key, Config $config, BootstrapConfigModel $model)
 {
     $model->form_default_horizontal = $config->get('form.default-horizontal');
     $model->form_default_submit_btn = $config->get('form.default-submit-btn');
     $model->form_horizontal_label = $config->get('form.horizontal.label');
     $model->form_horizontal_control = $config->get('form.horizontal.control');
     $model->form_horizontal_offset = $config->get('form.horizontal.offset');
     $model->form_styled_select = $config->get('form.styled-select.enabled');
     $model->form_styled_select_class = $config->get('form.styled-select.class');
     $model->form_styled_select_style = $config->get('form.styled-select.style');
     $model->form_styled_select_size = $config->get('form.styled-select.size');
     $model->form_styled_select_threshold = $config->get('form.styled-select.search-threshold');
     $model->form_styled_select_format = $config->get('form.styled-select.selected-text-format');
     $model->form_styled_upload = $config->get('form.styled-upload.enabled');
     $model->form_styled_upload_class = $config->get('form.styled-upload.class');
     $model->form_styled_upload_position = $config->get('form.styled-upload.position');
 }
예제 #7
0
 /**
  * Generate the form.
  *
  * @param Config $config Bootstrap config.
  *
  * @return string
  */
 private function generateForm($config)
 {
     $config->set('runtime.modal-footer', '');
     $content = $this->getForm($this->form);
     $this->formButtons = $config->get('runtime.modal-footer');
     $config->set('runtime.modal-footer', false);
     // render style select if it is used
     // @codingStandardsIgnoreStart
     // TODO move this to an event or hook
     // @codingStandardsIgnoreEnd
     if ($this->isAjax && $config->get('form.styleSelect.enabled')) {
         $content .= sprintf('<script>jQuery(\'.%s\').selectpicker(\'render\');</script>', $config->get('form.styleSelect.class'));
     }
     return $content;
 }
예제 #8
0
 /**
  * Get a config value for a given form widget type.
  *
  * @param ContextualConfig|Config $config  The used config.
  * @param string                  $type    The widget type.
  * @param string                  $name    The configuration name.
  * @param mixed                   $default The default value.
  *
  * @return mixed
  */
 protected static function getWidgetConfigValue($config, $type, $name, $default = false)
 {
     return $config->get('form.widgets.' . $type . '.' . $name, $default);
 }
예제 #9
0
 /**
  * {@inheritdoc}
  */
 public function extractConfig($key, Config $config, BootstrapConfigModel $model)
 {
     $model->dropdown_toggle = $config->get($key . '.toggle');
     $model->dropdown_formless = $config->get($key . '.formless');
 }
예제 #10
0
 /**
  * {@inheritdoc}
  */
 public function extractConfig($key, Config $config, BootstrapConfigModel $model)
 {
     $model->modal_dismiss = $config->get('modal.dismiss');
     $model->modal_adjustForm = $config->get('modal.adjustForm');
 }
예제 #11
0
 /**
  * {@inheritdoc}
  */
 public function import($file)
 {
     return $this->local->import($file);
 }
예제 #12
0
 /**
  * Handle submit buttons added to a field.
  *
  * @param ContextualConfig|Config $config     The bootstrap config.
  * @param Container               $container  Form element container.
  * @param \Widget                 $widget     The form widget.
  * @param InputGroup              $inputGroup The input group.
  *
  * @return void
  */
 private function adjustSubmitButton($config, Container $container, \Widget $widget, InputGroup $inputGroup)
 {
     if ($container->hasChild('submit')) {
         /** @var Node $submit */
         $submit = $container->removeChild('submit');
         // recreate as button
         if ($submit->getTag() != 'button') {
             $submit = Element::create('button');
             $submit->setAttribute('type', 'submit');
             $submit->addChild($widget->slabel);
         }
         $submit->addClass('btn');
         if ($widget->bootstrap_addSubmitClass) {
             $submit->addClass($widget->bootstrap_addSubmitClass);
         } else {
             $submit->addClass($config->get('form.default-submit-btn'));
         }
         if ($widget->bootstrap_addSubmitIcon) {
             $icon = Bootstrap::generateIcon($widget->bootstrap_addSubmitIcon);
             $position = null;
             if ($widget->bootstrap_addSubmitIconPosition == 'left') {
                 $position = Node::POSITION_FIRST;
                 $icon .= ' ';
             } else {
                 $icon = ' ' . $icon;
             }
             $submit->addChild(new StaticHtml($icon), $position);
         }
         $inputGroup->setRight($submit, $inputGroup::BUTTON);
     }
 }