has_many

edited April 2013 in Modules
Is it possible to order items in the has_many selection boxes?

I've tried something like:
public $has_many = array( 'articles' => array('model' => array(NEWSLETTER_FOLDER => 'articles_model', 'order' => 'precedence ASC')) );
but it doesn't seem to have an effect.

Comments

  • edited 1:34PM
    I just posted a change to allow for that. Before you would have to overwrite your model's options_list method to order it.
  • edited April 2013
    I installed the latest Fuel (today) and tried this feature out again with
    public $has_many = array( 'articles' => array('model' => array(NEWSLETTER_FOLDER => 'articles_model', 'order' => 'precedence ASC')) );

    and it didn't seem to order the list on the left hand side according to the column specified.

    Also, although saving the items added to the right hand side works, it doesn't seem to save an emptied right hand side, or even a partially emptied one. Eg add 3 items to the right, save, remove 2 or more items and save, you still have 3 items in the right.

    I don't think the fuel_relationships table is being cleared on save?
  • edited 1:34PM
    The clearing on save should be fixed now. That is a recent regression bug. With regards to the sorting, I'm having a tough time replicating that error. Does it work if you use a different column?
  • edited 1:34PM
    Using the default generated tables, I tried sorting by 'content' and 'precedence', and the list still seems to be in 'name' order ascending regardless.

    The clearing of the fuel_relationships table is fine now though.
  • edited 1:34PM
    Try this syntax (note the slight difference in the array):
    public $has_many = array( 'articles' => array('model' => array(NEWSLETTER_FOLDER => 'articles_model'), 'order' => 'precedence ASC'));
Sign In or Register to comment.