diff --git a/corehq/apps/app_execution/forms.py b/corehq/apps/app_execution/forms.py index 317500f3c30e..7e6e40f0d1db 100644 --- a/corehq/apps/app_execution/forms.py +++ b/corehq/apps/app_execution/forms.py @@ -57,7 +57,6 @@ def __init__(self, request, *args, **kwargs): if self.instance.id: self.fields["username"].initial = self.instance.django_user.username self.helper = hqcrispy.HQFormHelper() - self.helper.form_class = "form-horizontal" fields = [ "name", diff --git a/corehq/apps/commtrack/forms.py b/corehq/apps/commtrack/forms.py index 1a046e636136..f5b22eca8c73 100644 --- a/corehq/apps/commtrack/forms.py +++ b/corehq/apps/commtrack/forms.py @@ -4,22 +4,22 @@ from django.utils.translation import gettext_lazy from django.utils.html import format_html -from crispy_forms.bootstrap import PrependedText, StrictButton -from crispy_forms.helper import FormHelper +from crispy_forms.bootstrap import StrictButton from crispy_forms.layout import Fieldset, Layout from corehq.apps.consumption.shortcuts import ( get_default_monthly_consumption, set_default_consumption_for_product, ) -from corehq.apps.hqwebapp.widgets import BootstrapCheckboxInput +from corehq.apps.hqwebapp.crispy import FormActions, HQFormHelper from corehq.apps.products.models import SQLProduct class CommTrackSettingsForm(forms.Form): - use_auto_emergency_levels = forms.BooleanField(label='', required=False, widget=BootstrapCheckboxInput( - inline_label=gettext_lazy("Use default emergency levels") - )) + use_auto_emergency_levels = forms.BooleanField( + label=gettext_lazy("Use default emergency levels"), + required=False, + ) stock_emergency_level = forms.DecimalField( label=gettext_lazy("Emergency Level (months)"), required=False) @@ -28,22 +28,25 @@ class CommTrackSettingsForm(forms.Form): stock_overstock_threshold = forms.DecimalField( label=gettext_lazy("Overstock Level (months)"), required=False) - use_auto_consumption = forms.BooleanField(label='', required=False, widget=BootstrapCheckboxInput( - inline_label=gettext_lazy("Use automatic consumption calculation") - )) + use_auto_consumption = forms.BooleanField( + label=gettext_lazy("Use automatic consumption calculation"), + required=False, + ) consumption_min_transactions = forms.IntegerField( label=gettext_lazy("Minimum Transactions (Count)"), required=False) consumption_min_window = forms.IntegerField( label=gettext_lazy("Minimum Window for Calculation (Days)"), required=False) consumption_optimal_window = forms.IntegerField( label=gettext_lazy("Optimal Window for Calculation (Days)"), required=False) - individual_consumption_defaults = forms.BooleanField(label='', required=False, widget=BootstrapCheckboxInput( - inline_label=gettext_lazy("Configure consumption defaults individually by supply point") - )) + individual_consumption_defaults = forms.BooleanField( + label=gettext_lazy("Configure consumption defaults individually by supply point"), + required=False, + ) - sync_consumption_fixtures = forms.BooleanField(label='', required=False, widget=BootstrapCheckboxInput( - inline_label=gettext_lazy("Sync consumption fixtures") - )) + sync_consumption_fixtures = forms.BooleanField( + label=gettext_lazy("Sync consumption fixtures"), + required=False, + ) def clean(self): cleaned_data = super(CommTrackSettingsForm, self).clean() @@ -66,8 +69,7 @@ def clean(self): def __init__(self, *args, **kwargs): domain = kwargs.pop('domain') - self.helper = FormHelper() - self.helper.label_class = 'form-label' + self.helper = HQFormHelper() self.helper.layout = Layout( Fieldset( @@ -78,20 +80,22 @@ def __init__(self, *args, **kwargs): ), Fieldset( _('Consumption Settings'), - PrependedText('use_auto_consumption', ''), + 'use_auto_consumption', 'consumption_min_transactions', 'consumption_min_window', 'consumption_optimal_window', - PrependedText('individual_consumption_defaults', ''), + 'individual_consumption_defaults', ), Fieldset( _('Phone Settings'), - PrependedText('sync_consumption_fixtures', ''), + 'sync_consumption_fixtures', ), - StrictButton( - _("Submit"), - type="submit", - css_class='btn-primary', + FormActions( + StrictButton( + _("Submit"), + type="submit", + css_class='btn-primary', + ) ) ) @@ -112,9 +116,8 @@ class ConsumptionForm(forms.Form): def __init__(self, domain, *args, **kwargs): self.domain = domain super(ConsumptionForm, self).__init__(*args, **kwargs) - self.helper = FormHelper() + self.helper = HQFormHelper() self.helper.form_tag = False - self.helper.label_class = 'form-label' layout = [] products = SQLProduct.active_objects.filter(domain=domain) diff --git a/corehq/apps/commtrack/templates/commtrack/manage/default_consumption.html b/corehq/apps/commtrack/templates/commtrack/manage/default_consumption.html index 8e56d4a4dbb4..d183ea909e4b 100644 --- a/corehq/apps/commtrack/templates/commtrack/manage/default_consumption.html +++ b/corehq/apps/commtrack/templates/commtrack/manage/default_consumption.html @@ -21,8 +21,12 @@ {% crispy form %} - +
form_class
, label_class
,
diff --git a/corehq/apps/hqwebapp/utils/bootstrap/changes_guide/css-form-group.md b/corehq/apps/hqwebapp/utils/bootstrap/changes_guide/css-form-group.md
index 7b6ac9575df2..b16cdcaa9098 100644
--- a/corehq/apps/hqwebapp/utils/bootstrap/changes_guide/css-form-group.md
+++ b/corehq/apps/hqwebapp/utils/bootstrap/changes_guide/css-form-group.md
@@ -1,10 +1,10 @@
`form-group` has been dropped. Use grid utilities instead.
-Since we are opting for vertical forms (where the label is directly above the field), take the following actions:
+Take the following actions:
* Remove the `div` wrapper from the `form-group`'s first child, which contains the field's label.
-* Remove the column classes (`col-lg-2`, etc.) from the `form-group`'s first child, usually a `