PHP code example of quansitech / qscmf-list-search-type-select2

1. Go to this page and download the library: Download quansitech/qscmf-list-search-type-select2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

quansitech / qscmf-list-search-type-select2 example snippets


composer 

    $user_list = D("User")->getField("id,name", true);
    
    (new \Qscmf\Builder\ListBuilder())
    ->addSearchItem('user_id', 'select2', '单选姓名', $user_list)
    ->display();
    
    

    for ($i=1;$i<=5;$i++){
      $children = [];
      for ($j=1;$j<=3;$j++){
          $children[] = ['id' => $i.'_'.$j, 'text' => $j.'子分类'];
      }
      $cate_list[] = ['text' => '父级分类'.$i, 'children' => $children];
    }
    
    (new \Qscmf\Builder\ListBuilder())
    ->addSearchItem('cate_id', 'select2', '单选分类', $cate_list)
    ->display();
    
    

  $user_list = D("User")->getField("id,name", true);
  
  // 该值为Select2Builder对象 
  $select2_obj = new Select2Builder($user_list);
  $select2_obj->setPlaceholder("请选择多选姓名");
  $select2_obj->setIsMultiple(true);
  $select2_obj->setWidth("100");
  
  (new \Qscmf\Builder\ListBuilder())
  ->addSearchItem('select2_obj', 'select2', '多选姓名', $select2_obj)
  ->display();  
  

  //$key 搜索栏name
  //$map_key 数据库字段值
  //$get_data $_GET数组
  // 返回值
  // [$map_key => $get_data[$key]]
  $map = array_merge($map, \Qs\ListSearchType\Select2\Select2::parse('project_id', 'project_id', $get_data));