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

    i have researched about different frameworks for PHP in the past month and Akelos has received so much praise (even though its quite small community-wise) that i thought i might give this one a chance. Big shout-outs to Bermi taht you pulled this off amlost by yourself!

    i am pretty new to using frameworks, no Ruby experience and have recently tried out Symfony (hard to install) and CodeIgniter (not even a real scaffolding feature) and i am now starting with a bigger project. i managed to take a few hurdles myself up to this point, but now i don't get any further:

    i have set up a many-to-many relation "Event -hasmany- Categories" and have worked my way through the tutorial (http://wiki.akelos.org/how-to-implement-many-to-many-relationships). Everything is working fine, but when i save my Event, i get the following error:

    Fatal error: Call to a member function isNewRecord() on a non-object in /var/www/akelos/lib/AkActiveRecord/AkAssociations/AkHasAndBelongsToMany.php on line 859

    To me it seems like
    $CollectionHandler->JoinObject =& $CollectionHandler->JoinObject->create(array($options['foreign_key'] => $object_id ,$options['association_foreign_key'] => $AssociatedItem->getId()));

    does not return a valid object, but why?

    Can anybody tell?

    Thakns,
    Tilluigi
    • CommentAuthorKaste
     

    that line creates the record in the join-table. maybe the parameters aren't right. you could 'var_dump-debug'.

    $options['foreign_key']

    $object_id

    $options['association_foreign_key']

    $AssociatedItem->getId()

    could be anything. probably just the configuration of the habtm.

    • CommentAuthortilluigi
     
    thanks kaste, in the meantime i restarted the whole project in MAMP and now it works.
    but now i have another question:

    in my _form.tpl for the event, i am using:

    $form_options_helper->select('event', 'category_id', $Category->collect($Category->find(), 'category_name', 'id'),array(),array('multiple'=>'true'));

    to create a select list with all the "Categories" for an event. but how do i tell this list to make the categories "selected" that are associated with this event.

    i tried:

    $form_options_helper->select('event', 'category_id', $Category->collect($Category->find(), 'category_name', 'id'), $Event->categories ,array('multiple'=>'true'));

    but it didn't work.

    i also found the line in the docs:

    "By default, $post.person_id is the selected option. Specify 'selected' => value to use a different selection or 'selected' => null to leave all options unselected."

    but i still do not understand what to do.

    thanks for your help.
    -tilluigi


    p.s.: how do i var_dump.debug?
    • CommentAuthorKaste
     

    the first version of your ->select()-statement works for 1-1 relations.

    select('event','category_id') means event has a property category_id which it hasnt.

    as fourth argument you pass $Event->categories which is the right direction. this argument takes

    array('selected'=>array_of_selected_values)
    

    puttin' it together

    $selected_categories = array_keys($Event->category->associated_ids);
    $form_options_helper->select('event', 'category_id', 
        $Category->collect($Category->find(), 'category_name', 'id'),
        array('selected'=>$selected_categories),array('multiple'=>'true'));
    

    ~

    • CommentAuthortilluigi
     
    thanks, that did the trick for me!

    now, how do i create multiple many-to-manys on my Event?
    • CommentAuthortilluigi
     
    ok, solved that one myself (well, almost).

    hey i am getting more and more into this - programming is fun again!