wagtail
wagtail copied to clipboard
wagtail forms placeholder
Is your proposal related to a problem?
If I'm not mistaken there is no way to add placeholders. When you create a forms via wagtail there is no way to add a placeholder.
Describe the solution you'd like
add besides help_text also placeholder to the form builder
No you have to override get_from method from AbstractForm class to do it. If you are beginner you don't know how to do this.
def get_form(self, *args, **kwargs):
form = super().get_form(*args, **kwargs)
for field in form.fields:
form.fields[field].widget.attrs['placeholder'] = form.fields[field].label
return form
Still think the formbuilder should have a placeholder field?
Added needs design decision. See https://github.com/wagtail/wagtail/issues/2328 for context but placeholder usage is considered a bit of an anti-pattern so we may not want to explicitly support this.
However, we should check how easy it is to use the documented approaches of overriding field attrs if someone wants to do this.
Personally I’d be ok with us adding support for placeholders in the form builder, as long as the help text for the field provides guidance on appropriate usage.
ok - will remove label - leave this open for someone to pick up if they want to implement a PR for this.