Question

I'm using DoctrineExtensions and followed the docs. I have my Entity field decorated with the Sluggable annotation:

   use Gedmo\Mapping\Annotation as Gedmo;
   .
   .
   .
   /**
     * @Gedmo\Slug(fields={"city"}, updatable=false)
     * @ORM\Column(length=255)
     */
    private $slug;

When I try to persist a new entity I get an SQL error:

Persist:

        $em = $this->getDoctrine()->getManager();
        $em->persist($location);
        $em->flush();

Error:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'slug' cannot be null

config.yml:

# Stof Doctrine Extensions
stof_doctrine_extensions:
    orm:
        default:
            sluggable: true

According to the docs this is all I need, yet the slug is not being generated.

Was it helpful?

Solution

This was something simple that I over looked. I did not have the field mapped in the orm.xml file... once I added this mapping it worked:

<field name="slug" type="string" column="slug" length="255" nullable="false">
    <gedmo:slug fields="city" updatable="false" />
</field>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top