dongmu5246 2016-07-23 12:00
浏览 5
已采纳

SilverStripe更改父类的字段标签

Within SiteConfig there is a TextField Site title. I'm trying to change the label of this textfield $titleField through a SiteConfig extension in class SiteConfigExtension extends DataExtension.

Here is the code from siteconfig/code/model/ where it's created:

$fields = new FieldList(
    new TabSet("Root",
        $tabMain = new Tab('Main',
            $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")),
                ....

Q: What's the easiest way to replace the SiteTitle label without having to remove the field in the SiteConfig extension and re-add it again with the desired label?

  • 写回答

2条回答 默认 最新

  • doudouchan5830 2016-07-24 07:26
    关注

    Updating the title from SiteConfigExtension uses updateCMSFields...

    class SiteConfigExtension extends DataExtension {
    
        public function updateCMSFields(FieldList $fields) {
            if ($titleField = $fields->dataFieldByName('Title'))
                $titleField->setTitle('my title');
        }
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计