By default the bootstrap date element has the container as wrapper class and col-sm-6 as column class. One of my projects I wanted to have fluid-container and col-sm-4 as wrapper class and column class respectively. So, I add two more options in formatter settings which user can control the wrapper and column classes based on bootstrap 4 system.

I hope that it will help somebody.

Comments

Orestis Nerantzis created an issue. See original summary.

Orestis Nerantzis’s picture

Issue summary: View changes
b_sharpe’s picture

I'm not sure why these options are necessary in the first place? They are determining layout, not anything to do with the widget itself. The layout in my opinion should be left to the form in which the field exists.

That said, if there is a valid reason to have the widget use these classes on the wrapping elements, then I support the patch at minimum.

jb.fresh’s picture

StatusFileSize
new61.2 KB

This patch seems to be a good path to fix some other issues with the layout that are introduced by the widget.

prashant.c’s picture

Status: Needs review » Needs work

@Orestis Nerantzis

I agree with @b_sharpe it a widget so do not need to add something for the layout but I tested it and found it could be useful sometimes, fixing a bit of layout issue of the field as well.

However there are few inputs :

1. Remove trailing spaces after $summary = []; and $elements = [];

modules/bootstrap_datetime_picker/src/Plugin/Field/FieldWidget/BootstrapDateTimeWidget.php

2. Need not to translate integers.

'#options' => [
        'col-sm-1' => $this->t('1'),
        'col-sm-2' => $this->t('2'),
        'col-sm-3' => $this->t('3'),
        'col-sm-4' => $this->t('4'),
        'col-sm-5' => $this->t('5'),
        'col-sm-6' => $this->t('6'),
        'col-sm-7' => $this->t('7'),
        'col-sm-8' => $this->t('8'),
        'col-sm-9' => $this->t('9'),
        'col-sm-10' => $this->t('10'),
        'col-sm-11' => $this->t('11'),
        'col-sm-12' => $this->t('12'),
      ],

3. Do not need extra single quotes in "<div class='" . $element['#wrapper_class'] . "'> and <div class='" . $element['#column_size_class'] . "'>";

Please fix, test these and resubmit the patch.

Thanks, nice work!

ayushmishra206’s picture

Status: Needs work » Needs review
StatusFileSize
new3.83 KB

I have made the changes requested in #5. please review

prashant.c’s picture

Status: Needs review » Fixed

Thanks to all of you. Pushed and released with tag 8.x-1.5. Please check at your end and feel free to re-open this ticket if any issue found.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.