Skip to content

Commit 689582d

Browse files
authored
Add max length option on Titleblocks that sets maxlength attribute. (#4546)
Fixes #4544
1 parent d05b98d commit 689582d

3 files changed

Lines changed: 1646 additions & 0 deletions

File tree

hypha/apply/funds/blocks.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ApplicationMustIncludeFieldBlock(MustIncludeFieldBlock):
2727
class TitleBlock(ApplicationMustIncludeFieldBlock):
2828
name = "title"
2929
description = "The title of the project"
30+
widget = forms.TextInput(attrs={"x-model.fill": "titleblock"})
3031
field_label = blocks.CharBlock(
3132
label=_("Label"), default=_("What is the title of your application?")
3233
)
@@ -35,11 +36,17 @@ class TitleBlock(ApplicationMustIncludeFieldBlock):
3536
label=_("Help text"),
3637
default=_("This project name can be changed if a full proposal is requested."),
3738
)
39+
max_length = blocks.IntegerBlock(required=False, label=_("Max length"))
3840

3941
class Meta:
4042
label = _("Application title")
4143
icon = "tag"
4244

45+
def get_field_kwargs(self, struct_value):
46+
kwargs = super().get_field_kwargs(struct_value)
47+
kwargs["max_length"] = struct_value["max_length"]
48+
return kwargs
49+
4350

4451
class ValueBlock(ApplicationSingleIncludeFieldBlock):
4552
name = "value"

0 commit comments

Comments
 (0)