Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yii\bootstrap\ButtonDropdown splitButton gets same options as primary button #108

Open
yii-bot opened this issue Jan 24, 2016 · 1 comment
Labels
type:enhancement Enhancement

Comments

@yii-bot
Copy link

yii-bot commented Jan 24, 2016

This issue has originally been reported by @ASlatius at yiisoft/yii2#6720.
Moved here by @cebe.


When rendering with 'split'=>true, the dropdown-toggle is rendered with a second button. This button gets the same options as the primary buttons.
This is getting problematic when you try and set options for JavaScript usage like 'id' and 'onclick'.

@ruturajmaniyar
Copy link

You can simply change on your code and resolved this issue.
In ButtonDropDown.php line number : 109, you can find below code.

if ($this->split) {
            $options = $this->options;
            $this->options['data-toggle'] = 'dropdown';
            Html::addCssClass($this->options, ['toggle' => 'dropdown-toggle']);
            unset($options['id']);
            $splitButton = Button::widget([
                'label' => '<span class="caret"></span>',
                'encodeLabel' => false,
                'options' => $this->options,
                'view' => $this->getView(),
            ]);
        } else {
            $label .= ' <span class="caret"></span>';
            $options = $this->options;
            Html::addCssClass($options, ['toggle' => 'dropdown-toggle']);
            $options['data-toggle'] = 'dropdown';
            $splitButton = '';
        }

you can change in above code, in "ELSE" part only and solved "splitButton" option issue.

else {
            $label .= ' <span class="caret"></span>';
            $options = $this->options;
            $options['data-toggle'] = 'dropdown';
            Html::addCssClass($options, ['toggle' => 'dropdown-toggle']);
            unset($options['id']);
            $splitButton = '';
        }

Here issue is that 'data-toggle' option want to add before "html" and need to unset "$options['id']" after html is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants