def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper.layout = Layout( Fieldset( "public_identifier", self._load_details_from_template( "Help with public identifiers", "regulations/help_public_identifiers.jinja", ), Field( "url", css_class="govuk-input", ), "regulation_group", self._load_details_from_template( "Help with regulation group", "regulations/help_regulation_group.jinja", ), "information_text", "start_date", "end_date", "published_at", HTML.details( "Help with Published date", RegulationFormBase.PUBLISHED_AT_HELP_TEXT, ), "approved", ), Submit( "submit", "Save", data_module="govuk-button", data_prevent_double_click="true", ), )
def _load_details_from_template(self, title, template_path): public_identifier_details_content = loader.render_to_string( template_path, ) return HTML.details( title, SafeString(public_identifier_details_content), )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( HTML.details( "Help with nationality", "We need to know your nationality so we can work out which " "elections you’re entitled to vote in. If you cannot provide " "your nationality, you’ll have to send copies of identity " "documents through the post.", ))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) kwargs.pop("initial") self.fields["geo_area"].initial = self.data.get(f"{self.prefix}-geo_area") geographical_area_fields = { GeoAreaType.ERGA_OMNES: self.erga_omnes_instance, GeoAreaType.GROUP: self.data.get(f"{self.prefix}-geographical_area_group"), GeoAreaType.COUNTRY: self.data.get( f"{self.prefix}-geographical_area_country_or_region", ), } nested_forms_initial = {} if self.fields["geo_area"].initial: nested_forms_initial["geographical_area"] = geographical_area_fields[ self.fields["geo_area"].initial ] self.bind_nested_forms(*args, initial=nested_forms_initial, **kwargs) self.helper = FormHelper(self) self.helper.label_size = Size.SMALL self.helper.legend_size = Size.SMALL self.helper.layout = Layout( "geo_area", HTML.details( "Help with geography", ( "Choose the geographical area to which the measure applies. This can be a specific country " "or a group of countries, and exclusions can be specified. The measure will only apply to imports " "from or exports to the selected area." ), ), Submit( "submit", "Continue", data_module="govuk-button", data_prevent_double_click="true", ), )