Ejemplo n.º 1
0
 def __init__(self, legend, *fields, **kwargs):
     self.fields = list(fields)
     self.legend = legend
     self.css_class = kwargs.pop('css_class', '')
     self.css_id = kwargs.pop('css_id', None)
     # Overrides class variable with an instance level variable
     self.template = kwargs.pop('template', self.template)
     self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 2
0
 def __init__(self, legend, *fields, **kwargs):
     self.fields = list(fields)
     self.legend = legend
     self.css_class = kwargs.pop('css_class', '')
     self.css_id = kwargs.pop('css_id', None)
     # Overrides class variable with an instance level variable
     self.template = kwargs.pop('template', self.template)
     self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 3
0
 def __init__(self, label, *fields, **kwargs):
     #TODO: Decide on how to support css classes for both container divs
     self.fields = list(fields)
     self.label_html = label
     self.label_class = kwargs.pop('label_class', u'blockLabel')
     self.css_class = kwargs.pop('css_class', u'ctrlHolder')
     self.css_id = kwargs.pop('css_id', None)
     self.template = kwargs.pop('template', self.template)
     self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 4
0
 def __init__(self, label, *fields, **kwargs):
     self.fields = list(fields)
     self.label_html = label
     self.label_class = kwargs.pop('label_class', u'blockLabel')
     self.css_class = kwargs.pop('css_class', u'ctrlHolder')
     self.css_id = kwargs.pop('css_id', None)
     self.template = kwargs.pop('template', self.template)
     self.field_template = kwargs.pop('field_template', self.field_template)
     self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 5
0
 def __init__(self, label, *fields, **kwargs):
     self.fields = list(fields)
     self.label_html = label
     self.label_class = kwargs.pop('label_class', u'blockLabel')
     self.css_class = kwargs.pop('css_class', u'ctrlHolder')
     self.css_id = kwargs.pop('css_id', None)
     self.template = kwargs.pop('template', self.template)
     self.field_template = kwargs.pop('field_template', self.field_template)
     self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 6
0
 def __init__(self, label, *fields, **kwargs):
     #TODO: Decide on how to support css classes for both container divs
     self.fields = list(fields)
     self.label_html = label
     self.label_class = kwargs.pop('label_class', u'blockLabel')
     self.css_class = kwargs.pop('css_class', u'ctrlHolder')
     self.css_id = kwargs.pop('css_id', None)
     self.template = kwargs.pop('template', self.template)
     self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 7
0
 def __init__(self, label, *fields, **kwargs):
     # TODO: Decide on how to support css classes for both container divs
     self.fields = list(fields)
     self.label_html = label
     self.label_class = kwargs.pop("label_class", u"blockLabel")
     self.css_class = kwargs.pop("css_class", u"ctrlHolder")
     self.css_id = kwargs.pop("css_id", None)
     self.template = kwargs.pop("template", self.template)
     self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 8
0
    def __init__(self, *fields, **kwargs):
        self.fields = list(fields)

        if hasattr(self, 'css_class') and kwargs.has_key('css_class'):
            self.css_class += ' %s' % kwargs.pop('css_class')
        if not hasattr(self, 'css_class'):
            self.css_class = kwargs.pop('css_class', None)

        self.css_id = kwargs.pop('css_id', '')
        self.template = kwargs.pop('template', self.template)
        self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 9
0
    def __init__(self, name, value, **kwargs):
        self.name = name
        self.value = value
        self.id = kwargs.get('css_id', '')
        self.attrs = {}

        if kwargs.has_key('css_class'):
            self.field_classes += ' %s' % kwargs.pop('css_class')

        self.template = kwargs.pop('template', self.template)
        self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 10
0
    def __init__(self, name, value, **kwargs):
        self.name = name
        self.value = value
        self.id = kwargs.get('css_id', '')
        self.attrs = {}

        if kwargs.has_key('css_class'):
            self.field_classes += ' %s' % kwargs.pop('css_class')

        self.template = kwargs.pop('template', self.template)
        self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 11
0
    def __init__(self, *fields, **kwargs):
        self.fields = fields

        if hasattr(self, 'css_class') and kwargs.has_key('css_class'):
            self.css_class += ' %s' % kwargs.pop('css_class')
        if not hasattr(self, 'css_class'):
            self.css_class = kwargs.pop('css_class', None)

        self.css_id = kwargs.pop('css_id', '')
        self.template = kwargs.pop('template', self.template)
        self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 12
0
    def __init__(self, *fields, **kwargs):
        self.fields = list(fields)

        if hasattr(self, "css_class") and kwargs.has_key("css_class"):
            self.css_class += " %s" % kwargs.pop("css_class")
        if not hasattr(self, "css_class"):
            self.css_class = kwargs.pop("css_class", None)

        self.css_id = kwargs.pop("css_id", "")
        self.template = kwargs.pop("template", self.template)
        self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 13
0
    def __init__(self, name, value, **kwargs):
        self.name = name
        self.value = value
        self.id = kwargs.get("css_id", "")
        self.attrs = {}

        if kwargs.has_key("css_class"):
            self.field_classes += " %s" % kwargs.pop("css_class")

        self.template = kwargs.pop("template", self.template)
        self.flat_attrs = flatatt(kwargs)
Ejemplo n.º 14
0
    def get_attributes(self):
        """
        Used by crispy_forms_tags to get helper attributes
        """
        items = {}
        items['form_method'] = self.form_method.strip()
        items['form_tag'] = self.form_tag
        items['form_style'] = self.form_style.strip()
        items['form_show_errors'] = self.form_show_errors
        items['help_text_inline'] = self.help_text_inline
        items['error_text_inline'] = self.error_text_inline
        items['html5_required'] = self.html5_required

        items['attrs'] = {}
        if self.attrs:
            items['attrs'] = self.attrs.copy()
        if self.form_action:
            items['attrs']['action'] = self.form_action.strip()
        if self.form_id:
            items['attrs']['id'] = self.form_id.strip()
        if self.form_class:
            # uni_form TEMPLATE PACK has a uniForm class by default
            if getattr(settings, 'CRISPY_TEMPLATE_PACK',
                       'bootstrap') == 'uni_form':
                items['attrs']['class'] = "uniForm %s" % self.form_class.strip(
                )
            else:
                items['attrs']['class'] = self.form_class.strip()
        else:
            if getattr(settings, 'CRISPY_TEMPLATE_PACK',
                       'bootstrap') == 'uni_form':
                items['attrs']['class'] = self.attrs.get('class',
                                                         '') + " uniForm"

        items['flat_attrs'] = flatatt(items['attrs'])

        if self.inputs:
            items['inputs'] = self.inputs
        if self.form_error_title:
            items['form_error_title'] = self.form_error_title.strip()
        if self.formset_error_title:
            items['formset_error_title'] = self.formset_error_title.strip()

        for attribute_name, value in self.__dict__.items():
            if attribute_name not in items and attribute_name not in [
                    'layout', 'inputs'
            ] and not attribute_name.startswith('_'):
                items[attribute_name] = value

        return items
Ejemplo n.º 15
0
    def get_attributes(self):
        """
        Used by crispy_forms_tags to get helper attributes
        """
        items = {}
        items['form_method'] = self.form_method.strip()
        items['form_tag'] = self.form_tag
        items['form_style'] = self.form_style.strip()
        items['form_show_errors'] = self.form_show_errors
        items['help_text_inline'] = self.help_text_inline
        items['error_text_inline'] = self.error_text_inline
        items['html5_required'] = self.html5_required

        items['attrs'] = {}
        if self.attrs:
            items['attrs'] = self.attrs.copy()
        if self.form_action:
            items['attrs']['action'] = self.form_action.strip()
        if self.form_id:
            items['attrs']['id'] = self.form_id.strip()
        if self.form_class:
            # uni_form TEMPLATE PACK has a uniForm class by default
            if getattr(settings, 'CRISPY_TEMPLATE_PACK', 'bootstrap') == 'uni_form':
                items['attrs']['class'] = "uniForm %s" % self.form_class.strip()
            else:
                items['attrs']['class'] = self.form_class.strip()
        else:
            if getattr(settings, 'CRISPY_TEMPLATE_PACK', 'bootstrap') == 'uni_form':
                items['attrs']['class'] = self.attrs.get('class', '') + " uniForm"

        items['flat_attrs'] = flatatt(items['attrs'])

        if self.inputs:
            items['inputs'] = self.inputs
        if self.form_error_title:
            items['form_error_title'] = self.form_error_title.strip()
        if self.formset_error_title:
            items['formset_error_title'] = self.formset_error_title.strip()

        for attribute_name, value in self.__dict__.items():
            if attribute_name not in items and attribute_name not in ['layout', 'inputs'] and not attribute_name.startswith('_'):
                items[attribute_name] = value

        return items