Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Observer_Slug when updating
  • Hi

    I'm using the slug observer in an Orm model, and it update slug when an object is updated with this call on my model


    For the example if i create a post with the title "My great post", the slug will be 'my-great-post', no problem. But when the post is updated, the slug change for 'my-great-post-2'.

    And if i add a 'before_insert' on the observer:

    'Orm\Observer_Slug' => array('events' => array('before_insert'))

    When updating, the slug change simply for 'NULL'.

    So is it a normal behavior to increment the slug on updating ? Or a bug, or i do something wrong ? Because i use slug in url and for evidents reasons, the slug jsut can't change everytime...

  • It should not do that.

    What Model are you using? And how exactly did you define the observer in your model? Is should be something like:

    protected static $_observers = array(
        'Orm\\Observer_Slug' => array(
            'events' => array('before_insert', 'before_update'),
            'source' => 'title',
            'property' => 'slug',

  • It's a model extended from Orm\Model_soft

    And i'm fully agree with you, it should not do that, but it does. I copy paste your code just in case but same result.

    Edit : Oh erf my bad, it came from a piece of code, sorry.
  • Ah, new information. Please try to be as precise as possible in your reports, it will save us both a lot of time.

    Observer_Slug was never supported for any model other then the standard ORM model. I added support for Model_Temporal 25 days ago (which I think made 1.6.1), it still has no support for Model_Soft. I can see if I can add that.
  • Did a quick check.

    Model_Soft comes with it's own Query class extension, that will inject a "WHERE yourdeletefield IS NULL" in every query generated. So that should work out of the box. Which Fuel version are you on?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion