diff --git a/wagtail/wagtailcore/blocks/field_block.py b/wagtail/wagtailcore/blocks/field_block.py index 4b65f770e1..7a79a25784 100644 --- a/wagtail/wagtailcore/blocks/field_block.py +++ b/wagtail/wagtailcore/blocks/field_block.py @@ -306,14 +306,17 @@ class RawHTMLBlock(FieldBlock): class ChooserBlock(FieldBlock): - def __init__(self, required=True, **kwargs): + def __init__(self, required=True, help_text=None, **kwargs): self.required = required + self.help_text = help_text super(ChooserBlock, self).__init__(**kwargs) """Abstract superclass for fields that implement a chooser interface (page, image, snippet etc)""" @cached_property def field(self): - return forms.ModelChoiceField(queryset=self.target_model.objects.all(), widget=self.widget, required=self.required) + return forms.ModelChoiceField( + queryset=self.target_model.objects.all(), widget=self.widget, required=self.required, + help_text=self.help_text) def to_python(self, value): # the incoming serialised value should be None or an ID diff --git a/wagtail/wagtailcore/tests/test_blocks.py b/wagtail/wagtailcore/tests/test_blocks.py index 39620a5c4b..4410004d29 100644 --- a/wagtail/wagtailcore/tests/test_blocks.py +++ b/wagtail/wagtailcore/tests/test_blocks.py @@ -1218,7 +1218,7 @@ class TestPageChooserBlock(TestCase): self.assertEqual(block.to_python(None), None) def test_form_render(self): - block = blocks.PageChooserBlock() + block = blocks.PageChooserBlock(help_text="pick a page, any page") empty_form_html = block.render_form(None, 'page') self.assertIn('', empty_form_html) @@ -1227,6 +1227,7 @@ class TestPageChooserBlock(TestCase): christmas_form_html = block.render_form(christmas_page, 'page') expected_html = '' % christmas_page.id self.assertIn(expected_html, christmas_form_html) + self.assertIn("pick a page, any page", christmas_form_html) def test_form_response(self): block = blocks.PageChooserBlock()