Kotti / deform_bootstrap

Bootstrap compatible templates for the deform form library. (Merged into deform 2.)
http://pypi.python.org/pypi/deform_bootstrap
34 stars 30 forks source link

Added tabbed forms #60

Closed nightmarebadger closed 11 years ago

nightmarebadger commented 11 years ago

Added option to add tabs to forms, using colander.Mapping() (each Mapping appears in a new tab on the form).

Form validation is changed so all forms with errors are highlighted, and the first tab with errors is automatically selected. Also fixed some problems with radio widgets using integers as ID's, fixing two problems in selenium tests on the way.

Added basic info about adding tabbed forms into the README.

kstrauser commented 11 years ago

What would be a good approach for making this configurable? We don't want to use tabs for each mapping and were surprised to see them popping up all over our UI. I was thinking of an approach like setting tabbed_mappings = True on a colander.Schema to enable this behavior, but what would be the right place for storing that configuration information?

dairiki commented 11 years ago

FWIW, I agree that the tabbed forms should be configurable. And they should be disabled by default, since it does result in a shocking change of appearance.

I think the option (if one is really needed) belongs on deform.widget.FormWidget. Really a new option is not needed — one can just point FormWidget.template to a tabbed (or non-tabbed) version of the form template.

dnouri commented 11 years ago

Thanks for your comments. It looks like we made a wrong decision when we decided to make the tabbed forms the unconfigurable default.

I agree with @dairiki's suggestion of setting FormWidget.template explicitly when the tabbed forms appearance is desired.

cc @nightmarebadger

kstrauser commented 11 years ago

@dnouri Just to be clear, I really like the tabbed forms and think they're a great option when appropriate. We were just surprised at the fairly large change in a patch release.

dairiki commented 11 years ago

Apologies if I sounded a little harsh. I totally agree with @kstrauser that the tabbed layout is a great option to have.

dnouri commented 11 years ago

No offense taken. Your feedback was most constructive.

J20S commented 8 years ago

Hi guys, I really love the tabbed form and thanks for providing this great function.

Recently I've been trying to internationalize my webapp by following the deform doc (http://deform.readthedocs.org/en/latest/i18n.html). However, after changing from the default renderer to the customised ZPT renderer where you can see in the link, I lose the tabbed forms. All the contents are now displayed in a vertical manner. Any hints on how to get this problem fixed?

Any help will be greatly appreciated!

Cheers, James

J20S commented 8 years ago

@dnouri @disko

disko commented 8 years ago

@J20S Tabbed forms don't exist in Deform, they're a feature of deform_bootstrap. You need to add the deform_bootstrap template dir to your custom renderer.

Please also note, that deform_bootstrap is no longer maintained. It has basically been merged into deform 2, without the tabs feature though (IIRC).

J20S commented 8 years ago

@disko Thanks for your comment and it worked!! Just so that everyone else knows, if you want to internationalize your webapp and do not want to lose the tabbed forms supported by bootstrap_deform. Make sure you create a customised ZPT renderer in the following way:

deform_template_dir = resource_filename('deform', 'templates/') deform_boostrap_template_dir = resource_filename('deform_bootstrap', 'templates/') def translator(term): return get_localizer(get_current_request()).translate(term) zpt_renderer = deform.ZPTRendererFactory( [deform_boostrap_template_dir,deform_templatedir], translator=translator) form = deform.Form(schema, buttons=(('Submit'),), renderer=zpt_renderer)

Please note, the order of the template directories does matter. Make sure deform_bootstrap template directory is before the deform template directory.