通过yii2 Html a()发送post parameteres

时间:2016-04-12 15:20:38

标签: php yii yii2

我试图通过yii \ bootstrap \ Html发送参数;

echo Html::a('Создать', ['/orders/order-create','freelancer_group'=>$_GET['freelancer_group']], ['class'=>'btn btn-lg btn-primary','data'=>['method' => 'post','derp'=>'herp'],]);

但是当我点击它时,var_dump($_POST['derp']);仍是NULL。我该如何发布?我找到了here

1 个答案:

答案 0 :(得分:5)

echo Html::a('Создать',
    ['/orders/order-create', 'freelancer_group' => $_GET['freelancer_group']],
    [
        'class' => 'btn btn-lg btn-primary',
        'data' => [
            'method' => 'post',
            'params' => ['derp' => 'herp'], // <- extra level
        ],
    ]
);