Projet

Général

Profil

0001-add-CheckboxesWidget.get_options-23403.patch

Anonyme, 25 avril 2018 17:09

Télécharger (1,58 ko)

Voir les différences:

Subject: [PATCH] add CheckboxesWidget.get_options (#23403)

 wcs/qommon/form.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
wcs/qommon/form.py
1109 1109
    def has_error(self, request=None):
1110 1110
        return Widget.has_error(self, request=request)
1111 1111

  
1112
    def get_options(self):
1113
        options = []
1114
        tags = []
1115

  
1116
        if self.options_with_attributes:
1117
            options = self.options_with_attributes[:]
1118

  
1119
        for option in options:
1120
            object, description, key = option[:3]
1121
            html_attrs = {}
1122
            html_attrs['value'] = key
1123
            if self.options_with_attributes and option[-1].get('disabled'):
1124
                html_attrs['disabled'] = 'disabled'
1125
            if self.options_with_attributes and option[-1].get('checked'):
1126
                html_attrs['checked'] = 'true'
1127
            if description is None:
1128
                description = ''
1129

  
1130
            yield {
1131
                'description': description,
1132
                'key': key,
1133
                'attrs': html_attrs,
1134
                'options': option[-1] if self.options_with_attributes else None
1135
            }
1136

  
1112 1137

  
1113 1138
class ValidatedStringWidget(StringWidget):
1114 1139
    '''StringWidget which checks the value entered is correct according to a regex'''
1115
-