Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带有搜索选项的joomla 3下拉列表框_Php_Joomla - Fatal编程技术网

Php 带有搜索选项的joomla 3下拉列表框

Php 带有搜索选项的joomla 3下拉列表框,php,joomla,Php,Joomla,我正在创建joomla 3自定义组件,在该组件中,我使用自定义字段类型(mycomponent/models/fields/productcategory.php)创建产品类别列表框。它还以正确的方式展示了产品 但我需要显示产品类别选择列表框,其中包含搜索选项,如模块管理器中的“位置”字段。我已经包括我的编码如下 `class JFormFieldProductCat extends JFormFieldList { /** * The form field t

我正在创建joomla 3自定义组件,在该组件中,我使用自定义字段类型(mycomponent/models/fields/productcategory.php)创建产品类别列表框。它还以正确的方式展示了产品

但我需要显示产品类别选择列表框,其中包含搜索选项,如模块管理器中的“位置”字段。我已经包括我的编码如下

    `class JFormFieldProductCat extends JFormFieldList
    {
    /**
     * The form field type.
     *
     * @var         string
     * @since       1.6
     */
    protected $type = 'ProductCat';

    /**
     * Method to get the field options.
     *
     * @return      array   The field option objects.
     * @since       1.6
     */
    public function getOptions()
    {
            // Initialize variables.
            $options = array();

            $db     = JFactory::getDbo();
            $query  = $db->getQuery(true);

            $query->select('id, productcat');
            $query->from('#__productcats AS a');
            $query->order('a.productcat');
            $query->where('published = 1');

            // Get the options.
            $db->setQuery($query);
            $options = array();
            $options[] = JHTML::_('select.option', '0', 'Select Category Name');

            $result = $db->loadObjectList();
            foreach($result as $row)
            {
      $options[] = JHTML::_('select.option', $row->id, $row->productcat);
            }
        // Check for a database error.
            if ($db->getErrorNum()) {
                    JError::raiseWarning(500, $db->getErrorMsg());
            }


            return $options;
    }
    }`
我找到了带有搜索选项的选择列表框的解决方案

这里是我找到的selectbox搜索解决方案的链接(),这里是编码

jQuery(document).ready(function($) {
         $( "#jform_fk_productcat" ).combobox();
         $( "#toggle" ).click(function() {
         $( "#jform_fk_productcat" ).toggle();
         });
         });
       jQuery(document).ready(function($) {
       $( "#jform_fk_product_code" ).combobox();
       $( "#toggle" ).click(function() {
       $( "#jform_fk_product_code" ).toggle();
      });
     });
但我比这更能解决问题。。请参考此url以获得更好的解决方案

您希望您的o/p是这样->@ashish yes select2比selectlistbox更好()您知道,select2将如何在我们的自定义组件中实现吗