【发布时间】:2014-07-15 22:29:43
【问题描述】:
我有名为 attribute 和 attribute set 的数据对象
属性集与属性有这种many_many关系
private static $many_many = array(
'Attributes' => 'Attribute'
);
属性我有这个
private static $belongs_many_many = array(
'Sets' => 'AttributeSet'
);
您可以直接从集合中或在属性上向集合添加属性。 现在我需要知道何时将新属性添加到集合中,以便之后更新另一个内容。我试过了
public function onBeforeWrite(){
parent::onBeforeWrite();
if( $this->isChanged('Attributes') ){
$this->Title = 'test';
}
}
在属性集上,但就像假设的那样,它不起作用,因为如果添加了新属性,则不会写入set get。
有没有办法做到这一点?
提前谢谢你
【问题讨论】:
-
更新了我的答案(你是否也收到了警报?)
标签: silverstripe