如何使用fuelCMS 1.4对has_many选择器进行拖放排序?

时间:2017-08-30 14:33:16

标签: fuelcms

我创建了一个模型并添加了$ has_many来选择多个产品。这工作正常,但我无法通过拖放使所选产品排序。我知道这是可能的,我已经看过了。但我无法在文档中找到任何显示如何完成此操作的内容。这是我的模特:

<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once(FUEL_PATH.'models/Base_module_model.php');

/**
 * This model handles setting up the form fields for our contact form
 *
 */

class Products_category_model extends Base_module_model {

    public $required = array('name', 'published');
    public $has_many  = array('products' => array(FUEL_FOLDER => 'Products_model'));


    function __construct()
    {
        parent::__construct('w_product_categories');
    }

    /*
        This will provide the list of records for display in the Admin Panel
        Note how the "excerpt" will display, but truncated

        Because we are using some MySQL functions in our select statement,
        we pass FALSE in as the second parament to prevent CI auto escaping of fields
    */
    function list_items($limit = null, $offset = null, $col = 'name', $order = 'asc', $just_count = false)
    {
        $this->db->select('id, name, published', FALSE);
        $data = parent::list_items($limit, $offset, $col, $order);
        return $data;
    }

    function form_fields($values = array(), $related = array())
    {
        $fields = parent::form_fields($values, $related);
        return $fields;
    }
}

class Product_category_model extends Base_module_record {
}

1 个答案:

答案 0 :(得分:0)

所以我发现这很简单。我在表单字段函数中添加了这个:

    // Makes the has many drag and drop sortable.
    $fields['products']['sorting'] = TRUE;
    $fields['products']['after_html'] = "<div style=\"clear:both;font-style:italic\">NOTE: you can sort selected product to your choosing by clicking on the product and then dragging it into the desired placement in the list</div>";
相关问题