Exemplo n.º 1
0
    def extractData(self):
        """ Override to be able to provide defaults
        """
        data, errors = Form.extractData(self)

        for k, v in data.items():
            if not v:
                default = getattr(self, 'default_' + k, None)

                if default:
                    value = data[k] = default()

                    if not value:
                        continue
                    widget = self.widgets[k]
                    widget.value = value
                    field = widget.field.bind(self.context)
                    field.default = value
                    widget.field = field
                    widget.ignoreRequest = True
                    widget.update()

        return data, errors