2012-08-17 42 views
0

我有我的窗體類:取消設置嵌入形式

public function configure() 
{ 
     $emb = $this->getEmbeddedForms(); 
     foreach($emb as $key => $form) 
     { 
      unset($form['backup']); 
     } 
} 

但這不工作 - 不要清除。 在$ EMB我有:

oneForm 
twoForm 

在oneForm和twoForm我有插件備份。我想用getEmbeddedForms取消設置。我無法在oneForm.class和twoForm.class中取消設置。

回答

1

你應該重新嵌入unset後您的形式。

public function configure() 
{ 
    $emb = $this->getEmbeddedForms(); 

    foreach($emb as $key => $form) 
    { 
    unset($form['backup']); 

    // re-embed the current form (it will override the previous one) 
    $this->embedForm($key, $form); 
    } 
} 
0

毫無疑問。您指定$this->getEmbeddedForms()的本地變量的內容$emb; - ))...想一想。

所以:

<?php 
// ... 

public function configure() { 
foreach($this->getEmbeddedForms() as $key => &$form) { 
    unset($form['backup']); 
} 
} 
?> 
+0

這也沒有工作 – 2012-08-17 11:07:19

+0

給更新的版本試試; - ))... – thedom 2012-08-17 11:09:38

+0

現在我有錯誤「致命錯誤:在無法創建一個臨時數組表達的元素的引用」 – 2012-08-17 11:14:48