예제 #1
0
 def render_footer(self, form_info=None):
     f = super(HorizontalFormView, self).render_footer(form_info=form_info)
     if not f:
         return ""
     
     return element("div", {"class": "form-group"},
                    element("div", self.field_div_attrs_no_label, f))
예제 #2
0
    def __html__(self):
        l = ""
        if self.view.label_args:
            l = element("div", self.view.label_args, "")

        i = Markup('<div class="checkbox"><label>{} {}</label>{}{}</div>')\
            .format(self.render_input(),
                    self.field.label.text,
                    self.render_description(),
                    self.render_errors())
        
        if self.view.field_div_attrs:
            i = element("div", self.view.field_div_attrs, i)

        return l+i
예제 #3
0
    def __html__(self):
        try:
            if self.field.widget.suppress_form_decoration:
                return self.field.widget(self.field)
        except:
            pass

        if self.view.want_labels:
            l = self.render_label()
            

            if l is None:
                field_div_attrs = self.view.field_div_attrs_no_label
                l = ""
            else:
                field_div_attrs = self.view.field_div_attrs
        else:
            field_div_attrs = self.view.field_div_attrs
            l = ""
        
        i = Markup("{}{}{}").format(self.render_input(),
                                    self.render_description(),
                                    self.render_errors())
        
        if field_div_attrs:
            i = element("div", field_div_attrs, i)

        return l+i
예제 #4
0
 def render(self, view, **kwargs):
     if not self.content:
         return ""
     
     c = Markup("").join((i.render(self) if isinstance(i, FormButton) else i
                          for i in self.content))
     return element("div", self.get_div_attrs(), c)
예제 #5
0
 def render_footer(self, form_info=None):
     if not self.buttons:
         return ""
     
     c = Markup("").join((i.render(self, form_info=form_info)
                          if isinstance(i, FormButton) else i
                          for i in self.buttons))
     return element("div", self.button_bar_attrs, c)
예제 #6
0
    def render(self, form, form_info=None):
        contents=Markup("{}{}{}{}").format(
            form.hidden_tag(),
            self.hidden_errors(form),
            self.render_fields(form, form_info=form_info),
            self.render_footer(form_info=form_info)
        )
        
        attrs = dict(self.form_attrs)
        if any((isinstance(i, FileField) for i in form)):
            attrs["enctype"] = "multipart/form-data"

        attrs["method"] = self.method
            
        return element("form", attrs, contents)
예제 #7
0
    def render_field(self, field, **kwargs):
        try:
            if field.widget.suppress_form_decoration:
                return field.widget(field)
        except:
            pass

        cls = "form-group row"
        if field.errors:
            cls += " has-error"
        if field.flags.required:
            cls += " required"
            
        return element("div", {"class": cls},
                       super(VerticalFormView, self).render_field(field,
                                                                  **kwargs)) 
예제 #8
0
 def render_description(self):
     if self.field.description:
         return element("p", self.view.description_attrs,
                        self.field.description)
     else:
         return ""
예제 #9
0
 def render_errors(self):
     if self.field.errors:
         return Markup("").join((element("p", self.view.error_attrs, i)
                                 for i in self.field.errors))
     else:
         return ""
예제 #10
0
 def render_input(self):
     c = Markup("").join(Markup('<li class="checkbox"><label>{} {}</label></li>')\
                         .format(i(),
                                 i.label.text) for i in self.field)
     return element("ul", {"class": "unstyled"}, c)
예제 #11
0
 def render_input(self):
     v = self.view.get_formfield_view()
     c = Markup("{}{}").format(self.field.hidden_tag(),
                                  v.render_fields(self.field,
                                                  form_info=self.form_info))
     return element("div", v.form_attrs, c)