0

我创建了一个模型并添加了 $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 {
}
4

1 回答 1

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>";
于 2017-08-30T18:33:33.867 回答