Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to override the label and help text on a FieldPanel?

Tags:

wagtail

I'd like to change the help text and the label for some of the Page fields in the admin interface. It seems like normally the FieldPanel picks up the label and help text from the model field, but since I'm wanting to change these values for fields on the Page model (title and search_description, specifically), I can't set verbose_name and help_text on the field itself

I tried passing in the heading and help_text keyword arguments to FieldPanel, but I'm still seeing the default label and help text in the admin interface.

class MyPage(Page):
    content_panels = [
        FieldPanel('title', heading='Name', classname='full'),
        FieldPanel('search_description', heading='Description',
                   classname='full',
                   help_text='Description used in indices and search results')
    ]

1 Answers

There is a way to overwrite the default help_text and label (called verbose_name) on a per-field basis.

MyPage._meta.get_field("title").help_text = "Help me Obi-Wan, you're my only help_text"
MyPage._meta.get_field("title").verbose_name = "Jedi Labelling"

enter image description here

There's this method. And then there's also the MultiFieldPanel's heading which Dan Swain had covered nicely in his answer.

And if all that doesn't quite work, there's always the Wagtail HelpPanel. More on that in the docs at http://docs.wagtail.io/en/v2.6.1/reference/pages/panels.html#helppanel

I've also created a YouTube video around this subject if you prefer to learn from videos.

Hope this helps!

like image 56
Kalob Taulien Avatar answered Oct 20 '25 03:10

Kalob Taulien