【问题标题】:Silverstripe 3.1 Change the default button text of the Gridfield Add button?Silverstripe 3.1 更改 Gridfield 添加按钮的默认按钮文本?
【发布时间】:2015-03-21 14:45:16
【问题描述】:

如何更改Gridfield 添加按钮的默认按钮文本? 我想这与 ->getConfig() 有关,有什么想法吗?

【问题讨论】:

  • 这是越来越近了吗? getConfig()->getComponentsByType('GridFieldAddNewButton')->setButtonName('Add Extra Product Gallery Images')
  • 我认为是。很多只有一个“s”。 $gridField->getConfig()->getComponentByType('GridFieldAddNewButton')->setButtonName('Add Extra Product Gallery Images');
  • 您也可以在数据对象中定义私有静态 $singular_name 和 $plural_name,因为“添加”按钮默认采用此功能。
  • 非常感谢,这两个答案都有效!

标签: silverstripe


【解决方案1】:

通过以下示例之一更改 Gridfield 添加按钮的默认按钮文本:

//$gridfield = ..... // define you gridfield as normal first...then
$gridfield->getConfig()->getComponentByType('GridFieldAddNewButton')->setButtonName('Add Extra Product Gallery Images');

或将其添加到您的数据对象中:

static $singular_name = "Add Extra Product Gallery Image";
static $plural_name = "Add Extra Product Gallery Images";

【讨论】:

  • 您好@user3257693,很高兴看到您解决了您的问题并感谢您分享解决方案。您能否将您的答案标记为已接受,以便人们可以轻松看到此问题已解决?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-10-31
  • 1970-01-01
  • 2013-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多