Ask your Symfony questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Sluggable integrity constraint problem Symfony

I need an answer to this question on the symphony forum :


Answers (3)


José Nahuel Cuesta Luengo answers:

Could you provide a little more details? Have you changed anything in the default logic for the Sluggable behavior?

Joel Gaujard comments:

No change made about Sluggable behavior.

José Nahuel Cuesta Luengo comments:

Have you tried adding unique: false as an option to the Sluggable behavior?

Joel Gaujard comments:

Sorry. I have to use slug as a unique data.


Luis Cordova answers:

obviously you are not supposed to play with slugs like that,

"When i create two article object with that same title (e.g. 'sale'), i have in my DB records with sale, sale-1 slugs." The slugs are different for the objects you created, you are creating the objects with same title but not assigning the same slugs.


"When i update object title to other (e.g. 'test'), everything goes fine. But when i change 'test' title to 'sale' back, i receive error:"

obviously unreasonable, you should not manually edit slugs like that to make them collide, or you should use a proper constraint validator to avoid for such a clash, if you are trying to purposefully make it

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'sale-1-lt' for key 'article_translation_sluggable_idx'

Joel Gaujard comments:

I don't modify slug by myself. Doctrine do it for me.

Luis Cordova comments:

of course but you tell it in code

show your code

Joel Gaujard comments:

Do you want to see the code of my form ?

Luis Cordova comments:

yes, you should post it to github or something, my skype is cordova_luis

Luis Cordova comments:

have you tried what Benjamin said below?


Benjamin Lévêque answers:

there is a known bug when using both i18n and sluggable.

you need to copy the file lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Template/Listener/Sluggable.php inside your own lib directory.

the you must edit the file following that instructions