且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 symfony2 奏鸣曲管理包中设置默认值

更新时间:2022-02-09 22:21:56

我想您现在可能已经解决了这个问题,但是作为对其他人的参考,您可以覆盖 getNewInstance() 方法并将默认值设置为对象:

I presume you've probably already solved this by now, but as a reference to anyone else you can override the getNewInstance() method and set the default value on the object:

public function getNewInstance()
{
    $instance = parent::getNewInstance();
    $instance->setName('my default value');

    return $instance;
}