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

Button Group Support #580

Closed
scuml opened this issue Apr 18, 2016 · 6 comments
Closed

Button Group Support #580

scuml opened this issue Apr 18, 2016 · 6 comments

Comments

@scuml
Copy link
Contributor

scuml commented Apr 18, 2016

Searched online and through the source and cannot find how one can implement button groups? Is this possible in 1.6.0? I'd be interested in coding a patch to support this feature if not.

http://v4-alpha.getbootstrap.com/components/buttons/#checkbox-and-radio-buttons
http://foundation.zurb.com/sites/docs/v/5.5.3/components/button_groups.html

Tags: button-group btn-group

@scuml
Copy link
Contributor Author

scuml commented May 9, 2016

There are two different patterns at play here. The standard button group can be implemented with the following code:

ButtonHolder(
    Submit('save_changes', 'Save changes', css_class="btn-primary"),
    Submit('cancel', 'Cancel'),
    css_class='btn-group'
),

The checkbox/radio button group (http://v4-alpha.getbootstrap.com/components/buttons/#checkbox-and-radio-buttons) requires a more significant coding change to the inline radio select code:

  • class="btn-group" data-toggle="buttons" needs to be added to a div after the parent label element, that wraps the child radio inputs and labels
  • an active class needs to be added to the radio label if initial value is set
  • the individual radio labels need a user defined class

This doesn't fit naturally into the crispy code base. Attaching the zipped class and template to manually add to any project that might need it.

Implementation

from custom_crispy import RadioButtons, CheckboxButtons
helper.layout = Layout(
        RadioButtons('radio_buttons', option_label_class="btn btn-info",),
        CheckboxButtons('checkboxes'),
)

Result
screen shot 2016-05-09 at 11 12 28 am

Attached Code
radiocheckbox-buttongroups.zip

@scuml scuml closed this as completed May 9, 2016
@scuml
Copy link
Contributor Author

scuml commented May 9, 2016

Branch diff if anyone is interested.
dev...scuml:button-group-support

@carltongibson
Copy link
Collaborator

@scuml Thanks for the input here. It's interesting. Not sure what to say re an issue or not. Maybe one for the docs or a blog post or something.

@fladi
Copy link
Contributor

fladi commented Oct 23, 2016

I need this regularly, can we get this merged somehow?

@zoidyzoidzoid
Copy link
Contributor

It'd be awesome to get some tests and docs on that branch, but if you're willing to make a PR for that branch, that'd be awesome, and I'll have a look when I can.

@FlowFX
Copy link

FlowFX commented Mar 1, 2017

Thanks @scuml for the solution to my problem! :D

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

No branches or pull requests

5 participants