def get_form(self, form_class): fg = FormGroup(**self.get_form_kwargs()) for kind in self.address_kinds: fg.add_form_def(kind, form_class=self.address_form_classes.get(kind, self.address_form_class)) if self.company_form_class: fg.add_form_def("company", self.company_form_class, required=False) return fg
def get_form(self, form_class=None): kwargs = self.get_form_kwargs() instance = kwargs.pop("instance", None) if not instance.pk: kwargs["initial"] = dict(self.request.GET.items()) fg = FormGroup(**kwargs) form_parts = self.get_form_parts(instance) for form_part in form_parts: for form_def in form_part.get_form_defs(): fg.form_defs[form_def.name] = form_def fg.instantiate_forms() return fg
def make_form_group(**kwargs): AddressForm = modelform_factory(Address, fields=("name", )) fg = FormGroup(**kwargs) fg.add_form_def("address1", AddressForm, required=True) fg.add_form_def("address2", AddressForm, required=False) fg.add_form_def("general", GeneralForm, required=True) return fg
def get_form(self, form_class): contact = get_person_contact(self.request.user) form_group = FormGroup(**self.get_form_kwargs()) form_group.add_form_def("billing", AddressForm, kwargs={"instance": contact.default_billing_address}) form_group.add_form_def("shipping", AddressForm, kwargs={"instance": contact.default_shipping_address}) form_group.add_form_def("contact", PersonContactForm, kwargs={"instance": contact}) return form_group
def get_form(self, form_class): kwargs = self.get_form_kwargs() fg = FormGroup(data=kwargs.get("data"), files=kwargs.get("files")) fg.add_form_def("billing", self.billing_address_form_class) fg.add_form_def("shipping", self.shipping_address_form_class) fg.add_form_def("order", self.order_form_class, kwargs={ "basket": self.request.basket, "shop": self.request.shop }) return fg
def make_form_group(**kwargs): AddressForm = modelform_factory(MutableAddress, fields=("name", )) fg = FormGroup(**kwargs) fg.add_form_def("address1", AddressForm, required=True) fg.add_form_def("address2", AddressForm, required=False) fg.add_form_def("general", GeneralForm, required=True) return fg
def get_form(self, form_class): kwargs = self.get_form_kwargs() fg = FormGroup(data=kwargs.get("data"), files=kwargs.get("files")) fg.add_form_def("billing", self.billing_address_form_class) fg.add_form_def("shipping", self.shipping_address_form_class) fg.add_form_def( "order", self.order_form_class, kwargs={"basket": self.request.basket, "shop": self.request.shop} ) return fg
def get_form(self, form_class): fg = FormGroup(**self.get_form_kwargs()) for kind in self.address_kinds: fg.add_form_def(kind, form_class=self.address_form_classes.get(kind, self.address_form_class)) if self.company_form_class and not self.request.customer: fg.add_form_def("company", self.company_form_class, required=False) return fg