Issue #4 new

checkbox can't handle multiple value with the same name

newlix
created an issue

In class FormRenderer {{{

!python

def checkbox(self, name, value="1", checked=False, label=None, id=None, 
             **attrs):
    """
    Outputs checkbox input.
    """

    id = id or name
    return tags.checkbox(name, value, self.value(name), label, id, **attrs)

}}} But the value of a checkbox might be a list. The following code might work. Thank you. {{{

!python

    def checkbox(self, name, value="1", checked=False, label=None, id=None, 
                 **attrs):
        """
        Outputs checkbox input.
        """

        id = id or name
        if isinstance(self.value(name),list):
            if value in self.value(name):
                checked=True
        else:
            checked = self.value(name)
        return tags.checkbox(name, value,checked , label, id, **attrs)

}}}

Comments (1)

  1. Log in to comment