public function saveWidgets($model)
 {
     if (isset($_POST['widgets'])) {
         foreach ($model->layout_widgets as $lw) {
             if (!array_key_exists($lw->id, $_POST['widgets'])) {
                 $lw->delete();
             }
         }
         $count = count($_POST['widgets']);
         foreach ($_POST['widgets'] as $index => $widget) {
             if ($index == 'copyMe') {
                 continue;
             }
             $layoutWidget = SystemLayoutsWidgets::model()->findByPk($index, 'layout_id = :layout_id', array(':layout_id' => $model->id));
             if ($layoutWidget) {
                 $layoutWidget->attributes = $widget;
                 $layoutWidget->save();
             } else {
                 $newLayoutWidget = new SystemLayoutsWidgets();
                 $newLayoutWidget->attributes = $widget;
                 $newLayoutWidget->layout_id = $model->id;
                 $newLayoutWidget->save();
             }
         }
     }
 }