i want to update field in db with juisortable but i was stuck here for 3days…
i have this in my view
<?php
// Organize the dataProvider data into a Zii-friendly array
$items = CHtml::listData(HelpContent::model()->findAllBySql('select * from help_content where id_help_menu = '.$_GET['id'].' order by weight asc'), 'id_help_content', 'name');
// Implement the JUI Sortable plugin
$this->widget('zii.widgets.jui.CJuiSortable', array(
'id' => 'item',
'items' => $items,
'tagName'=>'ol',
'itemTemplate'=>'<li id="{id}" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>{content}</li>',
'options'=>array(
'delay'=>100,
'placeholder'=>'ui-state-highlight',
'cursor'=>'move',
'update'=>"js:function(){
$.ajax({
type: 'POST',
url: '{$this->createUrl('helpContent/sort')}',
data: $(this).sortable('serialize'),
});
}",
),
));
?>
im my controller
public function actionSort()
{
foreach ($_POST['id'] as $position => $item)
{
$content = HelpContent::model()->findByPk($item);
$content->weight = $position;
return $content->save();
/*$connection=Yii::app()->db;
$connection->active=true;
$sql = 'update help_content set weight = :weight
where id_help_content = :id_help';
$command=$connection->createCommand($sql);
$command->bindParam(":id_help",$item,PDO::PARAM_STR);
$command->bindParam(":weight",$position,PDO::PARAM_STR);
$command->execute();*/
}
}
my rules
array('allow',
'actions'=>array('sort'),
'users'=>$admin,
),
what am i doing wrong???
please your help…
thanks in advance