Yii2-Sortable-Input

This is the forum for the yii2-sortable-input extension for Yii framework 2.0. This widget extends the yii2-sortable features by allowing you to drag drop lists and grids and store and save the sort order list…

Refer documentation and demos.

Hi Kartik-v,

I had a problem when setting up this extension where the field value not changing while new item add to their column.

I attached an image to show my problem clrearly.

Here’s my view




<?php

use yii\helpers\Html;

use kartik\sortinput\SortableInput;


use app\models\Menu;


/* @var $this yii\web\View */

$this->title = 'Sortable Input';

$this->params['breadcrumbs'][] = $this->title;

?>

<div class="site-about">

    <h1><?= Html::encode($this->title) ?></h1>

</div>


<div class="row">

    <div class="col-sm-3">

        <h3>Left Column</h3>

    <?php 

        $leftmenus=Menu::find()

                ->where(['position' => 'left'])

                ->all();


        $litems = [];

        foreach ($leftmenus as $lmenu) {

            $litems[$lmenu->id] = [

                                'content' => $lmenu->name,

                                'options' => ['data' => ['id'=>$lmenu->id]],

                            ];

        }


        echo SortableInput::widget([

            'name'=>'left-column',

            'items' => $litems,            

            'hideInput' => false,

            'sortableOptions' => [

                'itemOptions'=>['class'=>'alert alert-info'],

                'connected'=>true,

            ],

            'options' => ['class'=>'form-control', 'readonly'=>true]

        ]);

     ?>

    </div> <!-- /.col-sm-3 -->


    <div class="col-sm-3">

        <h3>Center Column</h3>

    <?php 

        $centermenus=Menu::find()

                ->where(['position' => 'center'])

                ->all();


        $citems = [];

        foreach ($centermenus as $cmenu) {

            $citems[$cmenu->id] = [

                                'content' => $cmenu->name,

                                'options' => ['data' => ['id'=>$cmenu->id]],

                            ];

        }


        echo SortableInput::widget([

            'name'=>'center-column',

            'items' => $citems,            

            'hideInput' => false,

            'sortableOptions' => [

                'itemOptions'=>['class'=>'alert alert-success'],

                'connected'=>true,

            ],

            'options' => ['class'=>'form-control', 'readonly'=>true]

        ]);

     ?>

    </div> <!-- /.col-sm-3 -->


    <div class="col-sm-3">

        <h3>Right Column</h3>

    <?php 

        $rightmenus=Menu::find()

                ->where(['position' => 'right'])

                ->all();


        $ritems = [];

        foreach ($rightmenus as $rmenu) {

            $ritems[$rmenu->id] = [

                                'content' => $rmenu->name,

                                'options' => ['data' => ['id'=>$rmenu->id]],

                            ];

        }


        echo SortableInput::widget([

            'name'=>'right-column',

            'items' => $ritems,            

            'hideInput' => false,

            'sortableOptions' => [

                'itemOptions'=>['class'=>'alert alert-danger'],

                'connected'=>true,

            ],

            'options' => ['class'=>'form-control', 'readonly'=>true]

        ]);


     ?>

    </div> <!-- /.col-sm-3 -->


</div> <!-- /.row -->



and my database if need it




--

-- Table structure for table `menu`

--


CREATE TABLE IF NOT EXISTS `menu` (

  `id` int(11) NOT NULL,

  `name` varchar(255) DEFAULT NULL,

  `position` varchar(255) DEFAULT NULL,

  `ordering` int(11) DEFAULT NULL

) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1;


--

-- Dumping data for table `menu`

--


INSERT INTO `menu` (`id`, `name`, `position`, `ordering`) VALUES

(1, 'Menu 1', 'left', 1),

(2, 'Menu 2', 'left', 2),

(3, 'Menu 3', 'left', 3),

(4, 'Menu 4', 'left', 4),

(5, 'Menu 5', 'left', 5),

(6, 'Menu 6', 'center', 6),

(7, 'Menu 7', 'center', 7),

(8, 'Menu 8', 'center', <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />,

(9, 'Menu 9', 'center', 9),

(10, 'Menu 10', 'center', 10),

(11, 'Menu 11', 'right', 11),

(12, 'Menu 12', 'right', 12),

(13, 'Menu 13', 'right', 13),

(14, 'Menu 14', 'right', 14),

(15, 'Menu 15', 'right', 15);


--

-- Indexes for dumped tables

--


--

-- Indexes for table `menu`

--

ALTER TABLE `menu`

  ADD PRIMARY KEY (`id`);


--

-- AUTO_INCREMENT for dumped tables

--


--

-- AUTO_INCREMENT for table `menu`

--

ALTER TABLE `menu`

  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=16;



Thanks for help and a great extension.

Did anyone manage to fix this issue? Experiencing the same problem like many others. Only I have no idea how to get this fixed.