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

Add support for Bootstrap 3 templates #209

Closed
jamesmfriedman opened this issue Jul 7, 2013 · 18 comments
Closed

Add support for Bootstrap 3 templates #209

jamesmfriedman opened this issue Jul 7, 2013 · 18 comments

Comments

@jamesmfriedman
Copy link
Contributor

Bootstrap is going into RC for version 3. It contains some minor modifications to the the form template structure, noticeably how horizontal forms are rendered (they now use the grid layout system).

@jamesmfriedman
Copy link
Contributor Author

@maraujop, I'm going to go ahead and duplicate the bootstrap template pack and make a bootstrap_v3 template pack to maintain backwards compat. I'll send a pull request when I'm done so you can check it out.

@maraujop
Copy link
Contributor

Thanks James! I really appreciate your effort, what do you think of naming it simply bootstrap3 ?

Cheers,
Miguel

@jamesmfriedman
Copy link
Contributor Author

Sure. On looking over it some more it's probably going to require some python changes as well, but I'll see what I can do.

Sent from my iPhone

On Jul 27, 2013, at 2:58 PM, Miguel Araujo notifications@github.com wrote:

Thanks James! I really appreciate your effort, what do you think of naming it simply bootstrap3 ?

Cheers,
Miguel


Reply to this email directly or view it on GitHub.

@jamesmfriedman
Copy link
Contributor Author

@maraujop Didn't take as long as I thought it would. Check it out. I did a little cleanup around some of the layout objects as well.

@rh0dium
Copy link

rh0dium commented Jul 31, 2013

@maraujop Can you please merge this in. I would rather pull from you than @jamesmfriedman although I will.

@vgarvardt
Copy link

This feature is really wanted. It would be very nice to merge it into master and release new version on pypi.

@maraujop
Copy link
Contributor

maraujop commented Aug 3, 2013

Hi @vgarvardt and @rh0dium I've just merged this in into dev branch. Version 1.4.0 will be released soon, no official date yet. Sorry for the delay, but I needed some time to review this patch. Meanwhile you can point your requirements to Github or clone dev branch.

Cheers,
Miguel

@jamesmfriedman
Copy link
Contributor Author

Thanks Miguel. Apparently the checkboxes are borked. I thought I checked them... Anyways, worth a look, probably something simple.

@jamesmfriedman
Copy link
Contributor Author

@maraujop Definitely don't do a release until Bootstrap3 is out of RC! Those guys are having a party changing things in the 9th inning...I'm going to make another pull request with some more of the changes they've recently implemented.

@jamesmfriedman jamesmfriedman reopened this Aug 6, 2013
@vkhemlan
Copy link

Hi! I've been using the latest dev commit of crispy forms in order to play with the Bootstrap 3 support. The only thing I'm missing is the support for horizontal forms (http://getbootstrap.com/css/#forms-horizontal).

To support them I manually changed the bootstrap3/field.html template to add the "col-xx" classes and setting the "form-horizontal" class when creating the FormHelper for my form.

Is this the correct way to go for now or is there a more elegant way? (One that doesn't involve modifying the source code of the project).

Thanks!

@jamesmfriedman
Copy link
Contributor Author

This is just my opinion, but I think trying to accommodate this would be a lot of clutter in the code. When I get into horizontal forms or more detailed layouts, I tend to just use the as_crispy_field filter and just write the surrounding stuff manually in the templates. Anyone else got any thoughts on it?

Sent from my iPhone

On Aug 14, 2013, at 5:51 PM, Vijay Khemlani notifications@github.com wrote:

Hi! I've been using the latest dev commit of crispy forms in order to play with the Bootstrap 3 support. The only thing I'm missing is the support for horizontal forms (http://getbootstrap.com/css/#forms-horizontal).

To support them I manually changed the bootstrap3/field.html template to add the "col-xx" classes and setting the "form-horizontal" class when creating the FormHelper for my form.

Is this the correct way to go for now or is there a more elegant way? (One that doesn't involve modifying the source code of the project).

Thanks!


Reply to this email directly or view it on GitHub.

@danielmt
Copy link

I've patched the fields I'm using, but it gives the idea. It adds vars label_class and field_class to the templates.

Usage:

        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-10'

incomplete patch: https://gist.github.com/danielmt/6250312

@orymate
Copy link

orymate commented Aug 19, 2013

Ticket about horizontal forms: #223

@camilonova
Copy link
Contributor

@maraujop since bootstrap is already released, do you have an ETA for version 1.4.0 ?

@camilonova
Copy link
Contributor

Accordion was changed to Collapsible, will not be better to change the name of the objects as well?

https://github.com/maraujop/django-crispy-forms/blob/dev/crispy_forms/bootstrap.py#L267

I can create Collapsible and CollapsibleGroup and add them to keep backwards compatibility, do you think is worth?

camilonova added a commit to camilonova/django-crispy-forms that referenced this issue Aug 23, 2013
camilonova added a commit to camilonova/django-crispy-forms that referenced this issue Aug 23, 2013
@maraujop maraujop reopened this Aug 28, 2013
@maraujop
Copy link
Contributor

Ok,

Based on Daniel's ( @danielmt ) work, I've pushed a patch for bootstrap 3 horizontal forms. It works the same way as his usage. Thanks Daniel, next time feel free to open a Pull Request. BTW I've added you to CONTRIBUTORS file.

self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-lg-2'
self.helper.field_class = 'col-lg-10'

It is now working with all layout objects, AFAIK. I consider this unfinished, I want to add tests and think some use cases carefully. I will keep this thread updated.

@camilonova I think version 1.4.0 will be hopefully released this week. I want to work on docs and tests, meanwhile people can tests some recent changes. BTW at the moment I don't it's worth renaming those layout objects, let's keep them like they are.

Cheers,
Miguel

@camilonova
Copy link
Contributor

Cool, thanks

Camilo Nova
Sent from my iPhone

On Wednesday, 28 de August de 2013 at 13:22, Miguel Araujo wrote:

Ok,
Based on Daniel's ( @danielmt (https://github.com/danielmt) ) work, I've pushed a patch for bootstrap 3 horizontal forms. It works the same way as his usage.
self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-2' self.helper.field_class = 'col-lg-10'

It is now working with all layout objects, AFAIK. I consider this unfinished, I want to add tests and think some use cases carefully. I will keep this thread updated.
@camilonova (https://github.com/camilonova) I think version 1.4.0 will be hopefully released this week. I want to work on docs and tests, meanwhile people can tests some recent changes. BTW at the moment I don't it's worth renaming those layout objects, let's keep them like they are.
Cheers,
Miguel


Reply to this email directly or view it on GitHub (#209 (comment)).

@IvanAnishchuk
Copy link

filter doesn't work with horizontal forms. Docstring says to use {{ myform|label_class:"col-lg-2",field_class:"col-lg-8" }}, but it won't work. And there is currently no way in django to pass multiple arguments to filter. Please, add some custom arguments parsing or something.

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

9 participants