contao / core-bundle

[READ-ONLY] Contao Core Bundle
GNU Lesser General Public License v3.0
123 stars 58 forks source link

Remove required attribute when chosen is enabled #423

Closed Toflar closed 8 years ago

Toflar commented 8 years ago

This will prevent the unfocusable javascript error in Chrome. We'll have to see if we can switch to a different script than Chosen in the future which supports html5 validation as well (and as a best case scenario is vanilla JS).

Not exactly sure how to fix this though. What do you think about this:

diff --git a/src/Resources/contao/widgets/SelectMenu.php b/src/Resources/contao/widgets/SelectMenu.php
index 1428147..4f39f8b 100644
--- a/src/Resources/contao/widgets/SelectMenu.php
+++ b/src/Resources/contao/widgets/SelectMenu.php
@@ -152,6 +152,7 @@ class SelectMenu extends \Widget
        if ($this->chosen)
        {
            $strClass .= ' tl_chosen';
+           unset($this->arrAttributes['required']);
        }

        return sprintf('<select name="%s" id="ctrl_%s" class="%s%s"%s onfocus="Backend.getScrollOffset()">%s</select>%s',
ghost commented 8 years ago

The issue has been moved to contao-components/chosen#2.