ifusion
ifusion

Reputation: 2233

How to add a description to a model managed via ModelAdmin?

I have a model managed via model admin, I want to add a description below the gridfield. Usually this is accomplished by setting ->setDescription('Note in here')

How do you do this when it is managed via the ModelAdmin?

<?php

class FormDropdownModelAdmin extends ModelAdmin {

    private static $managed_models = array(
        'HearAboutUsItem'
    );

    private static $url_segment = 'form-dropdown-items';

    private static $menu_title = 'Form Dropdown Items';

}

Upvotes: 2

Views: 230

Answers (1)

cryptopay
cryptopay

Reputation: 1082

You can overload the getEditForm method on your ModelAdmin and apply a description to the field.

public function getEditForm($id = NULL, $fields = NULL) {
    $form = parent::getEditForm($id, $fields);

    $form->Fields()->fieldByName('HearAboutUsItem')
        ->setDescription('This is my description');
    return $form;
}

Upvotes: 3

Related Questions