Ticket #1045: django.checkbox.patch

File django.checkbox.patch, 1.1 KB (added by andreas@…, 19 years ago)
  • django/core/formfields.py

     
    398398        checked_html = ''
    399399        if data or (data is '' and self.checked_by_default):
    400400            checked_html = ' checked="checked"'
    401         return '<input type="checkbox" id="%s" class="v%s" name="%s"%s />' % \
    402             (self.get_id(), self.__class__.__name__,
    403             self.field_name, checked_html)
     401        html_values = {
     402            'id' : self.get_id(),
     403            'class_name' : self.__class__.__name__,
     404            'name' : self.field_name,
     405            'checked_html' : checked_html }
     406        html_output = []
     407        html_output.append('<input type="checkbox" id="%(id)s" class="v%(class_name)s" name="%(name)s"%(checked_html)s />')
     408        html_output.append('<input type="hidden" id="%(id)s_check" name="%(name)s_check" value="1"/>')
     409        return ''.join(html_output) % html_values
    404410
    405411    def html2python(data):
    406412        "Convert value from browser ('on' or '') to a Python boolean"
Back to Top