开发者

How to embed a Form with an m:n (many to many) relation into an other?

I have a genereated form which handles a m:n relation. The generated form overrides the doSave() method to handle the "list".

开发者_JS百科

If I embed this Form in an other the special doSave() mothod is never called. The result is that everything works fine except that the m:n relation isn't stored.

Do I have to handle the m:n relation manuel?

Thanks


The better using sf 1.4 is using in your form class

public function configure() {
    $this->embedRelation('relationName'); 
    //other configuration
}

This work 'as this' for update/insert operations but your model relationship definition must be clear.

For further relation integration, you can override sfForm or sfDoctrineForm methods (especially doBind, doUpdateObject, saveEmbeddedForms) to add selective deletion, specific data binding, etc.

A good arcticle on this topic can be found here It is symfony 1.3 but the same pattens applies.

The good argument for this kind of implementation is that you have nothing to change in your module's actions.class.php and thus avoid creating dependency on form with its (or their) associated module.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜