def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.disable_csrf = True
self.helper.layout = Layout(
Fieldset(
'Owner Information',
Div(
Div('owner_full_name', css_class='col-md-4'),
css_class='row',
),
Div(
Div('owner_mailing_address', css_class='col-md-4'),
css_class='row',
),
Div(
Div('owner_city', css_class='col-md-3 city'),
Div('owner_province_state', css_class='col-md-1'),
Div('owner_postal_code', css_class='col-md-3 postal'),
css_class='row',
),
)
)
super(WellOwnerForm, self).__init__(*args, **kwargs)
# Make fields required on the form even though they are not required in the DB due to legacy data issues
# TODO - check admin or staff user and don't make these fields required
self.fields['owner_postal_code'].required = True
# display code instead of the value from __str__ in the model
self.fields['owner_province_state'].label_from_instance = self.label_from_instance_code
try:
bc = ProvinceState.objects.get(code='BC')
self.initial['owner_province_state'] = bc
self.fields['owner_province_state'].empty_label = None
except Exception as e:
pass
评论列表
文章目录