Is there any method in yii2 to post value to a redirect page?
Before using yii2, i use a button that invoke this javascript function:
function postToUrl(url, params, newWindow)
{
var form = $(document.createElement( 'form' ))
.attr( {'method': 'post', 'action': url} );
if(newWindow){ form.attr('target', '_blank'); }
$.each( params, function(key,value){
$.each( params instanceof Array? value : [value] ,function(i,val){
$(document.createElement('input'))
.attr({ 'type': 'hidden', 'name': key, 'value': val })
.appendTo( form );
});
} );
form.appendTo( document.body ).submit();
form.remove();
}
in yii2 i try this in a controller
return $this->redirect(['/eprv2-perumahan-iklan/open'], [
'data'=>[
'method' => 'post',
'params'=>[
'noic' => $model->nokp,
'noicp' => $model->nokp_pasangan,
],
]
]);
but on the redirected page, $post = Yii::$app->request->post() seem to be empty.
Please show me the correct way to do this in yii2?