1

I have a tree node in my form. I am using kartik-v's Tree Manager. This is my view code:

echo TreeViewInput::widget([ 
  'query'             => Tree::find()->addOrderBy('root, lft'), 
  'headingOptions'    => ['label' => 'Set Permission'],
  'name'              => 'name',    
  'value'             => '1,2,3',     
  'asDropdown'        => false,           
  'multiple'          => true,            
  'fontAwesome'       => true,            
  'rootOptions'       => [
    'label' => '<i class="fa fa-tree"></i>', 
    'class' => 'text-success'
]);

But, in this I have to follow the same table structure as mentioned in the widget. I have some extra fields and more permissions. So it is a bit complicated to use the same structure.

Is it possible to pass the value in an array directly to this widget? If possible let me know the array format.

Now I am stuck with this tree node implementation.

robsch
  • 9,358
  • 9
  • 63
  • 104
Sruthy
  • 47
  • 5

1 Answers1

1

You can do this by doing some tricks, or by using another way:

1) you can add a condition to your query like this:

Tree::find()->andWhere(['not in','id',[2,3,4]])->addOrderBy('root, lft'), 

by this solution you can ignore unwanted rows like you send data direct in array...

2) you can use another solution by using js lib/plugin direct like jsTree, in this case you can create and pass custom array direct...look at this example: jsTree Example

Anees Hikmat Abu Hmiad
  • 3,460
  • 2
  • 19
  • 36