Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Are everthing correct with those observers?
  • I have observer events are not working. This is how I do it:

    class Model_Someclass extends \Orm\Model
    {
        protected static $_table_name = 'someclasses';
        protected static $_primary_key = array('id');
    ...
    protected static $_observers = array(
            'Orm\Observer_CreatedAt' => array(
                'events'          => array('before_insert'),
                'property'        => 'created_at',
                'mysql_timestamp' => false,
            ),
            'Orm\Observer_UpdatedAt' => array(
                'events'          => array('before_save'),
                'property'        => 'updated_at',
                'mysql_timestamp' => false,
            )
        );

    public function _event_before_insert()
        {
            \Log::debug('Created');
        }

        public function _event_before_save()
        {
            \Log::debug('Updated');
        }

    }

    It seems event functions never run. Maybe you will see some rough mistake, but I don't see.

    Please, help. Thank you.

    PS: I use fuelphp 1.8.
  • HarroHarro
    Accepted Answer
    You define observers to run, so they run.

    If you want to define observer methods in the model itself, you need to use Observer_Self instead.
  • Thank you, Harro! I found it too.

Howdy, Stranger!

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

In this Discussion