I am trying to setup Sluggable from StofDoctrineExtensionsBundle to generate slug based primary key id and name field

/**
 * @var string
 * @Gedmo\Slug(fields={"id","name"})
 * @ORM\Column(name="slug", type="string", length=255, unique=true)
 */
private $slug;

However It doesn't generate like id-name, only generates slug based name. Why does it happen?

没有正确的解决方案

其他提示

If your sluggable listener listens on Doctrine's prePersist operation ...

... then your entity does at that point not have an id because it was not yet persisted.

This explains the missing id in the slug.

Set SluggableListener to postPersist and it will work as desired.

Change Gedmo/Sluggable/SluggableListener's subscribed events to postPersist.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top