yii2 - katrik的可编辑扩展不起作用。

时间:2015-08-27 00:48:07

标签: yii2

我正在尝试使用katrik的可编辑扩展。我得到了它应该是的表,但是当我尝试编辑一行时,我在编辑窗口中收到此消息:“内部服务器错误”。在更新中,它确实有效。有什么想法吗?

我的控制器:

public function actionIndex()
{
$searchModel = new ParticipatedinSearch;

    $dataProvider = /*Interviews::candidatesForIndex();*/
    new ActiveDataProvider([
        'query' => Participatedin::find()->joinWith('can')]);
if (Yii::$app->request->post('hasEditable')) {

    $part = Yii::$app->request->post('editableKey');
    $model = Participatedin::findOne($part);

    $out = Json::encode(['output'=>'', 'message'=>'']);

    $post = [];
    $posted = current($_POST['wId']);
    $post['wId'] = $posted;

    if ($model->load($post)) {
        $model->wId = $post['wId'];
        $model->save();

        $output = '';

        if (isset($posted['wId'])) {
           $output =  Yii::$app->formatter->asInteger($model->wId, 9);
        } 

        $out = Json::encode(['output'=>$output, 'message'=>'']);
    } 
    // 
    echo $out;
    return;
} 

我的观点指数:

$gridColumns = [

       ['attribute'=>'cId',
          'label'=>'שם המועמד',
             'value'=>function($model){
            $firstName = $model->can->idCandidate0->firstName;
            $lastName = $model->can->idCandidate0->lastName;
            $name = $firstName.' '.$lastName;
            return $name;
        }
        ],
        ['attribute'=>'cId',
          'label'=>'מוסד לימודים',
             'value'=>function($model){
            $institution = $model->can->idCandidate0->institution;


            return $institution;
        }
        ],
   // 'cpId',
    [
    'class' => 'kartik\grid\EditableColumn',
    'attribute'=>'wId', 
    'value'=>function($model){
            $name = $model->can->ws->name;
          ///  $lastName = $model->can->idCandidate0->lastName;
          //  $name = $firstName.' '.$lastName;
            return $name;
        },

    'readonly'=>function($model, $key, $index, $widget) {
       // return (!$model->cpId); // do not allow editing of inactive records
    },
    'editableOptions' => [
        'header' => 'מקום עבודה',//INPUT_DROPDOWN_LIST
        'inputType' => \kartik\editable\Editable::INPUT_DROPDOWN_LIST,
         'data'=>[ArrayHelper::map(worksites::find()->all(), 'wId', 'name')],
        'options' => [
            'pluginOptions' => ['min'=>1, 'max'=>10]
        ]
    ],
    'hAlign'=>'middle', 
    'vAlign'=>'middle',
   'width'=>'290px',
  //  'format'=>['integer', 9],
    'pageSummary' => true,

],
              [
    'class' => 'kartik\grid\EditableColumn',
    'attribute'=>'director', 
     /*'value'=>function($model){
            $name = $model->director->name;
          ///  $lastName = $model->can->idCandidate0->lastName;
          //  $name = $firstName.' '.$lastName;
            return $name;
        }, */             
    'label'=>'רכז',
    'readonly'=>function($model, $key, $index, $widget) {
       // return (!$model->cpId); // do not allow editing of inactive records
    },
    'editableOptions' => [
        'header' => 'רכז',//INPUT_DROPDOWN_LIST
        'inputType' => \kartik\editable\Editable::INPUT_DROPDOWN_LIST,
        'data'=>[ArrayHelper::map(Directors::find()->all(), 'id', 'prId')],
          'options' => [
              //'pluginOptions' => ['min'=>1, 'max'=>10]
          ]
       ],
    'hAlign'=>'middle', 
    'vAlign'=>'middle',
    'width'=>'290px',
  //  'format'=>['integer', 9],
    'pageSummary' => true,

],
];

 // the GridView widget (you must use kartik\grid\GridView)
 echo \kartik\grid\GridView::widget([
//  'firstName',

'dataProvider' => $dataProvider,

'filterModel' => $searchModel,
   'export'=>false,
'columns' => $gridColumns,

]);

谢谢..

1 个答案:

答案 0 :(得分:1)

尝试在可编辑小部件中使用:'afterInput' => Html::hiddenInput('id',$data->id),