yiisoft / yii2-bootstrap4

Yii 2 Bootstrap 4 Extension
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
216 stars 106 forks source link

Custom controls implementation is not BC (might break layout/functionality) #165

Closed flaviovs closed 5 years ago

flaviovs commented 5 years ago

What steps will reproduce the problem?

Upgrade to 2.0.5.

What's expected?

Backward compatibility for sites using standard BS4 form-check* classes.

What do you get instead?

Broken layout. Broken functionality.

No way to fix without: 1) reverting commit 94e2ed1; or 2) downgrading to 2.0.4.

Additional info

Issue #150 ~makes BS4 custom controls the default~ forces BS4 custom controls. Although CCs are nice, not all sites want/need it. Some sites might be targeting BS4 classes .form-check, .form-check-label, etc., to implement custom behaviour using other CSS/JS plugins, and not want BS custom control. That's exactly what I am facing now. The problem with #150 is that it makes impossible to revert to standard forms without patching the code.

My suggestion: implement a "useCustomControls" property to toggle between standard and custom controls.

Q A
Yii vesion 2.0.21
PHP version 7.3
Operating system Debian Stretch
simialbi commented 5 years ago

What we could do is write some docs with an explanation how to reset forms to form-check* elements via container configuration. @samdark what do you think?

samdark commented 5 years ago

You mean widget factory? Yes. That's a good option.

simialbi commented 5 years ago

What I mean is: https://www.yiiframework.com/doc/guide/2.0/en/concept-configurations#application-configurations

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'extensions' => require __DIR__ . '/../vendor/yiisoft/extensions.php',
    'container' => [
        'definitions' => [
            'yii\widgets\LinkPager' => ['maxButtonCount' => 5]
        ],
        'singletons' => [
            // Dependency Injection Container singletons configuration
        ]
    ]
];
samdark commented 5 years ago

Yes. Meant the same.

flaviovs commented 5 years ago

Configuring the container and/or templates was my first guess to solve the issue in a global way after the upgrade, but I was really concerned about classes being unconditionally added like this:

https://github.com/yiisoft/yii2-bootstrap4/blob/4fe2a565a870d3c49f7a3b1a57d009488827a77a/src/ActiveField.php#L222-L226

Classes on L225-226 were form-check-* before, and there are many changes like this, where classes added seemingly unconditionally were replaced. That suggests that just configuring/templates may not allow the use of .form-* classes, but I am not sure about that and to be honest I didn't try it.