如何向通过 ModelAdmin 管理的模型添加描述?
How to add a description to a model managed via ModelAdmin?
我有一个通过模型管理员管理的模型,我想在 gridfield
下方添加描述。通常这是通过设置 ->setDescription('Note in here')
来完成的
当它通过 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';
}
您可以在您的 ModelAdmin 上重载 getEditForm 方法并对字段应用描述。
public function getEditForm($id = NULL, $fields = NULL) {
$form = parent::getEditForm($id, $fields);
$form->Fields()->fieldByName('HearAboutUsItem')
->setDescription('This is my description');
return $form;
}
我有一个通过模型管理员管理的模型,我想在 gridfield
下方添加描述。通常这是通过设置 ->setDescription('Note in here')
当它通过 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';
}
您可以在您的 ModelAdmin 上重载 getEditForm 方法并对字段应用描述。
public function getEditForm($id = NULL, $fields = NULL) {
$form = parent::getEditForm($id, $fields);
$form->Fields()->fieldByName('HearAboutUsItem')
->setDescription('This is my description');
return $form;
}