/**
* Renders [sortable lists](https://github.com/rubaxa/Sortable) for selecting multiple data with order. It
* contains left and right blocks with draggable items between them.
* @param array $left Items for left block (selected items).
* @param array $right Items for right block.
* @param array $options
* @return $this
* @throws \yii\base\InvalidConfigException
*/
public function sortable($left, $right, $options = [])
{
$options = array_merge($this->inputOptions, $options);
$this->adjustLabelFor($options);
$options['value'] = '';
$html = Html::activeHiddenInput($this->model, $this->attribute, $options);
$leftBlock = Html::listGroupOrder($left, ['class' => 'sortable list-group-sm' . (count($left) > 0 ? '' : ' empty'), 'orderClass' => 'info']);
if (key($right) === 0) {
$rightBlock = Html::listGroupOrder($right, ['class' => 'sortable list-group-sm', 'title' => 'guid']);
} else {
$collapse = new Collapse();
$items = [];
foreach ($right as $label => $data) {
$items[] = ['label' => $label, 'content' => Html::listGroupOrder($data, ['class' => 'sortable list-group-sm', 'title' => 'guid']), 'options' => ['class' => 'panel-sortable']];
}
$collapse->items = $items;
$rightBlock = $collapse->renderItems();
}
$this->parts['{input}'] = $html . '<div class="row sortable-' . $this->attribute . '"><div class="col-md-6 sortable-left">' . $leftBlock . '</div><div class="col-md-6 sortable-right">' . $rightBlock . '</div></div>';
return $this;
}