PHP code example of izica / select-tree-view-for-backpack

1. Go to this page and download the library: Download izica/select-tree-view-for-backpack 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/ */

    

izica / select-tree-view-for-backpack example snippets


protected function setupCreateOperation()
{
     CRUD::addField([
        'view_namespace'    => 'izica::fields', // don't modify this field
        
        // REQUIRED
        'type'              => 'select_tree_view',
        'label'             => "Catalog category",
        'name'              => 'catalog_category_id',
        
        // in product view
        'options'           => CatalogCategory::get()->toArray(),
        // or in category view, with preventing loops on itself
        'options'           => CatalogCategory::whereNot('id', $this->crud->getCurrentEntryId())->get()->toArray(),
   
        // OPTIONAL
        'options_parent_id' => 'catalog_category_id',   // using value from 'name' param by default
        'depth_prefix'      => '.  ',                   //default value
        'depth_max'         => 10,                      //default value
        'options_root_id'   => null,                    //default value
        'options_sort_by'   => 'name',                  //default value
        'option_name'       => 'name',                  //default value
        'allows_null'       => true,                    //default value
        'default'           => null,                    //default value
    ]);
}