Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Conditions on HasOne relation
  • Hi, Are conditions on HasOne relationship supposed to work? Or is it still work in progress? It seems not to work for now. I would like to be able to do this:
    static::$_has_one['foo'] = array(
     'key_from' => 'id',
     'model_to' => 'Cms\Page\Model_Wysiwyg',
     'key_to' => 'foreign_id',
     'cascade_save' => true,
     'cascade_delete' => false,
     'conditions' => array(
      'where' => array(
       'wysiwyg_key' => 'cms_page.foo',
      ),
     ),
    );
    

    Right now I found this hacky way to simulate that:
    static::$_has_one['foo'] = array(
     'key_from' => array('id', 'class_var_defined_manually'),
     'model_to' => 'Cms\Page\Model_Wysiwyg',
     'key_to' => array('foreign_id', 'wysiwyg_key')
     'cascade_save' => true,
     'cascade_delete' => false,
    );
    

    It's also possible I didn't understood the 'conditions' properly. Thanks in advance for any answer. :-)

Howdy, Stranger!

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