开发者

Symfony Embedded Relation Many2Many - linking unique fields or creating new fields

开发者 https://www.devze.com 2023-02-12 17:29 出处:网络
I\'m using an embedded relation to allow the user to edit/add books to a library and in the same form to add/remove n authors who wrote the book within the auto generated admin.

I'm using an embedded relation to allow the user to edit/add books to a library and in the same form to add/remove n authors who wrote the book within the auto generated admin.

Here is my problem: An authors name is unique, so when I enter an author that already exists the sfValidatorDoctrineUnique produces the error.

An object with the same "name" already exist.

What I want to do is catch this error and tell the form not to try 开发者_如何学编程to add the exisiting author anew.

Do I use the event system for that, or modify the validators or how can I do that?

thank you very much hoodie

PS: after some searching I found something that might be a solution but I haven't made it work yet http://symfonyguide.wordpress.com/2009/09/28/symfony-forms-saving-process/


I my opinion you should not to add new author if it already exists.

sfDoctrineActAsTaggablePlugin do the same way. It searches for an existing tags and merge them with current (added by user from form) tags.

But here is one issue: Two authors - Aleksander Pushkin and Alexander Pushkin, is it same authors for us, but different for machine.

0

精彩评论

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