2011-07-22 19 views
0

我有一個採集表保存多個symfony的形式

class MyCollectionForm extends sfForm 
{ 
    public function configure() 
    { 
    parent::configure(); 

    $this->widgetSchema->setNameFormat('my_collection[%s]'); 

    $groups = Doctrine::getTable('QuotaGroup')->findAll(); //existing groups 
    foreach ($groups as $i => $group) 
    { 
     $groupForm = new QuotaGroupForm($group); 
     $this->embedForm($i, $groupForm); 
    } 

    $i++; 
    $this->embedForm($i, new QuotaGroupForm(new QuotaGroup())); //new group 

    $this->mergePostValidator(new QuotaGroupValidatorSchema()); 
    } 
} 

在保存動作我做的:

$this->form->bind($params); 
if($this->form->isValid()) 
{ 
    $this->form->save(); 
} 

我得到一個錯誤:調用未定義的方法MyCollectionForm ::保存()

我無法找到錯誤,因爲sfForm有一種保存方法...

+0

哇,這真的很奇怪!你可以檢查'MyCollectionForm instanceof sfForm'嗎?你有沒有在你的問題中使用複製/粘貼(包括錯誤信息?) – greg0ire

+0

不是關於嵌入式編程。重新標記。 –

回答

1

sfForm沒有保存方法...

您應該擴展sfFormDoctrine。

class MyCollectionForm extends sfFormDoctrine{ ...