From 6912d5398c56ea07c5ae05b18bea33529e3dfa98 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Thu, 12 Feb 2015 17:32:33 +0000 Subject: [PATCH] support required, help_text, max_length, min_length params on CharBlock --- wagtail/wagtailadmin/blocks.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wagtail/wagtailadmin/blocks.py b/wagtail/wagtailadmin/blocks.py index 9aa218554..57092bceb 100644 --- a/wagtail/wagtailadmin/blocks.py +++ b/wagtail/wagtailadmin/blocks.py @@ -314,9 +314,10 @@ class FieldBlock(Block): return self.field.clean(value) class CharBlock(FieldBlock): - field = forms.CharField() - # TODO: some kwargs, such as max_length, and *possibly* things like help_text, should be passed to - # the CharField constructor. Figure out a system for doing this + def __init__(self, required=True, help_text=None, max_length=None, min_length=None, **kwargs): + # TODO: decide what to do about 'label' and 'initial' parameters to the form field + self.field = forms.CharField(required=required, help_text=help_text, max_length=max_length, min_length=min_length) + super(CharBlock, self).__init__(**kwargs) class RichTextBlock(FieldBlock): @cached_property