我正在尝试在Yii2-Kartik Gridview中添加自己的操作按钮。 这是我的自定义按钮:
[
'class' => 'yii\grid\ActionColumn',
'template' => '{edit}',
'buttons' => [
'edit' => function ($url, $model) {
return Html::a('<button type="button" class="btn btn-edit-npwp"><i class="glyphicon glyphicon-plus-sign"></i></button>', $url, [
'title' => Yii::t('app', 'Edit'),
'data-toggle' => "modal",
'data-target' => "#myModal",
'data-method' => 'post',
]);
},
],
'urlCreator' => function ($action, $model, $key, $index) {
if ($action === 'edit') {
$url = Url::toRoute(['vatout-faktur-out/add-data', 'id' => $model->fakturId], ['data-method' => 'post',]);
return $url;
}
}
],
public function actionAddData($id) {
$model = new VatoutFakturOut();
return $this->render('addData', [
'model' => $model,
]);
}
我想处理我点击按钮的行中的数据。 但是,这个返回错误
缺少必需参数:id
由于
答案 0 :(得分:1)
在let continuousCollection = Array(0 ..< 10)
print(continuousCollection[0 ..< 5]) // [0, 1, 2, 3, 4]
print(continuousCollection[0 ... 5]) // [0, 1, 2, 3, 4, 5]
print(continuousCollection[4...]) // [4, 5, 6, 7, 8, 9]
print(continuousCollection[..<9]) // [0, 1, 2, 3, 4, 5, 6, 7, 8]
print(continuousCollection[...3]) // [0, 1, 2, 3]
中,您使用func popoverPresentationController(_ popoverPresentationController: UIPopoverPresentationController, willRepositionPopoverTo rect: UnsafeMutablePointer<CGRect>, in view: AutoreleasingUnsafeMutablePointer<UIView>)
{
rect.pointee = CGRect(x: self.view.frame.size.width, y: 0, width: 1, height: 1) // Set new rect here
}
语句进行检查,如果操作是bin/console sylius:install
,如果是,则将param urlCreator
添加到您的按钮网址。否则它没有一个,所以有两个解决方案:
从以下位置删除if
声明:
edit
或从id
中移除if
- 因为您根本不使用它:
'urlCreator' => function ($action, $model, $key, $index) {
$url = Url::toRoute(['vatout-faktur-out/add-data', 'id' => $model->fakturId]);
return $url;
}