2016-01-04 52 views
1

在我的控制,我想在我的實體更改兩個值(僅適用於指數「3):Symfony的不更新日期字段

$cle->getVersions()[0]->getLots()[3]->setTantieme(97); 
$cle->getVersions()[0]->getLots()[3]->setDateSuppression(new \DateTime); 
dump($cle); 
$em->flush(); 

但是,只有‘Tantieme’值改變我不。不懂在我的實體,我有:

/** 
* @var string 
* 
* @ORM\Column(name="date_suppression", type="datetime", nullable=true) 
*/ 
protected $date_suppression; 

public function setDateSuppression($date_suppression) 
{ 
    $this->date_suppression = $date_suppression; 
} 

public function getDateSuppression() 
{ 
    return $this->date_supppression; 
} 

這是一個特點它與其他實體的偉大工程,刷新之前

轉儲結果中庸之道:。 Image

Tantieme不斷更新,但絕不date_suppression ...

回答

0

儘量在setDateSuppression()方法返回 「東西」:

public function setDateSuppression($date_suppression) 
{ 
    $this->date_suppression = $date_suppression; 

    return $this; 
} 

編輯:

嘗試這樣的:

$cle->getVersions()[0]->getLots()[3]->setDateSuppression(new \DateTime()); 
+0

謝謝,但不工作太:/ –