def __call__(self, field, **kwargs): html = [] html.append('<div class="input-group">') for text in self.group_before: html.append('<span class="input-group-addon">%s</span>' % text) classes = kwargs.get("class_", "").split(" ") for class_ in self.default_classes: classes.append(class_) kwargs["class_"] = " ".join(classes) html.append(Input.__call__(self, field, **kwargs)) for text in self.group_after: html.append('<span class="input-group-addon">%s</span>' % text) html.append('</div>') return HTMLString("".join(html))
def test_input_type(self): with pytest.raises(AttributeError): Input().input_type test_input = Input(input_type="test") assert test_input.input_type == "test"
def test_input_type(self): with pytest.raises(AttributeError): getattr(Input(), "input_type") test_input = Input(input_type="test") assert test_input.input_type == "test"
def __init__(self, input_type=None, group_before=None, group_after=None, default_classes=None): self.group_before = group_before or [] self.group_after = group_after or [] self.default_classes = default_classes or [] Input.__init__(self, input_type=input_type)