Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorkkrzyzak
     

    Hi. I would like to create relationship between "Candle" model and "Category" model. It'll be "standard", has one relation. I would like to have in candles table one row with category id... However, I couldn't find any info about this relationship on akelos wiki. I've generated scaffold for candle model, and replaced standard input for category name to select with all categories: In candle controller: $this->category = new Category; $categories = $this->category->find('all'); foreach($categories as $category){ $this->categories[] = $category->name; } In candle _form.tpl: echo $form_options_helper->select('candle','category',$categories); Candle model: ` class Candle extends ActiveRecord { var $has_one = 'category';

    function validate(){
        $this->validatesUniquenessOf('name');
    }
    

    } category model: class Category extends ActiveRecord { var $belongs_to = 'candle'; } However, I've got some problems with add new candle - I've got this error: Fatal error: Could not load category on Candle because "Candle->category" attribute is already defided and can' be used as an association placeholder in /Applications/MAMP/htdocs/f1live/lib/AkActiveRecord/AkAssociation.php on line 60 ` IMO, I should edit something in candle model, but I don't know what and how ;)

    Sorry for my language errors - I'm still learning english ;)

    •  
      CommentAuthorbermi
     

    Fatal error: Could not load category on Candle because "Candle->category" attribute is already defided and can' be used as an association placeholder in /Applications/MAMP/htdocs/f1live/lib/AkActiveRecord/AkAssociation.php on line 60

    This means there is a collision between a column named 'category' in your Candle model, and having a belongs_to/has_one association named category.

    You'll need to set a different association handler name and specify the options like

    $has_one = array('group'=> array('class_name' => 'Category'));
    
    • CommentAuthorinsanet
     

    nevermind.