- Timestamp:
- 23 Dec 2011, 10:49:11 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/widgets/phonewidget.py
r7428 r7439 30 30 """ 31 31 import re 32 import copy 32 33 from waeup.sirp import MessageFactory as _ 33 34 from zope import schema … … 66 67 constraint=re.compile(r'^[0-9]{3,}$').search, 67 68 required=True) 68 69 69 70 70 class PhoneWidgetData(object): … … 129 129 """ 130 130 value = self.context.query(self.context.context) 131 adapters = {} 132 adapters[IPhoneData] = PhoneWidgetData(self, value) 131 # we have to modify the adapter according to our own 132 # 'required' state. Some ugly workaround 133 adapter = copy.deepcopy(IPhoneData) 134 for name in 'country', 'area', 'extension': 135 adapter[name].required = self.required 136 adapters = {adapter: PhoneWidgetData(self, value)} 133 137 self.widgets = form.setUpEditWidgets( 134 138 form.FormFields(IPhoneData), … … 164 168 self._error = None 165 169 try: 166 re turnu'-'.join((170 result = u'-'.join(( 167 171 self.widgets['country'].getInputValue(), 168 172 self.widgets['area'].getInputValue(), 169 173 self.widgets['extension'].getInputValue() )) 174 return result 175 except TypeError: 176 if self.required: 177 return self._missing 178 return None 170 179 except ValueError, v: 171 180 self._error = WidgetInputError( … … 173 182 raise self._error 174 183 except WidgetInputError, e: 175 # Subwidgets require input. We have to work around that if176 # the parent widget does not require input.177 missing = isinstance(e.errors, RequiredMissing)178 missing = missing or isinstance(e, MissingInputError)179 if not self.required and missing:180 return self._missing181 184 self._error = e 182 185 raise e
Note: See TracChangeset for help on using the changeset viewer.