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

    Hi, there.
    $form_option_helper->options_from_collection_for_select() can't work when I set 'id' the second parameter ($value_column_name).

    For example, this code (in a view file) shows a blank page.

    <select name="food_id">
      <option value=""></option>
      <?php echo $form_options_helper->options_from_collection_for_select(
        $params['food_id'] ? $params['food_id'] : ''
      ); ?>

    So, I edited lib/views/helpers/form_options_helper.php and fixed it.

    lib/views/helpers/form_options_helper.php line 194 -

    194    $name = method_exists($item,$text_column_name) ? $item->$text_column_name() : $item->get($text_column_name);  
    195    $collection_options[$name] = method_exists($item,$value_column_name) ? $item->$value_column_name() : $item->get($value_column_name);


    194    $name = method_exists($item,$text_column_name) ? $item->$text_column_name() : $item->get($text_column_name, false);  
    195    $collection_options[$name] = method_exists($item,$value_column_name) ? $item->$value_column_name() : $item->get($value_column_name, false);

    But I don't know whehere this solution is correct or not about a correct usage of this helper method.
    Is this modification correct?

    • CommentAuthorKaste

    get(attribute,false) is preventing to get the attribute from ->getId(), instead it uses $this->id.

    That's usually not what you want. Do you have modified ->getId() or getPrimaryKey()? Do you have a very large collection you loop over?

    my unit_test for this is:

    function testT()
        list($Food,) = $this->useModel('Food=>id,name');
        $n = 200;
        for ($i = 0;$i < $n;$i++){
            $this->createFood("name: Frucht$i");
        for ($i = 0;$i < ($n/5);$i++){
            $selected[] = rand(1,$n);
        $Form = new FormOptionsHelper();
        $form_string = $Form->options_from_collection_for_select(

    creates 200 items, selects a fifth of them randomly.