From be0bab1bb8da80402248cd1fa22fd4cc09b34fe7 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 25 May 2013 15:18:48 +0200 Subject: Fixed #11725 -- Made possible to create widget label tag without "for" Thanks Denis Martinez for the report and initial patch, and Sergey Kolosov for bringing the patch up to date. --- tests/forms_tests/tests/test_forms.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/forms_tests') diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 45e62a492c..f7eb46522f 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -1846,3 +1846,20 @@ class FormsTestCase(TestCase): self.assertHTMLEqual(boundfield.label_tag(), 'Field') self.assertHTMLEqual(boundfield.label_tag('Custom&'), 'Custom&') + + def test_boundfield_label_tag_custom_widget_id_for_label(self): + class CustomIdForLabelTextInput(TextInput): + def id_for_label(self, id): + return 'custom_' + id + + class EmptyIdForLabelTextInput(TextInput): + def id_for_label(self, id): + return None + + class SomeForm(Form): + custom = CharField(widget=CustomIdForLabelTextInput) + empty = CharField(widget=EmptyIdForLabelTextInput) + + form = SomeForm() + self.assertHTMLEqual(form['custom'].label_tag(), '') + self.assertHTMLEqual(form['empty'].label_tag(), '') -- cgit v1.3