Post Value

Hi all,

I am trying to retrieve the post value of one form field. I am using this:




Yii::$app->request->post('Name');



But this is not returning anything,

if i do:




Yii::$post->request->post();



I can see the field and the value, I just cant seem to access it.

Any ideas?

Regards

Matt

Are you sure it’s Name and not name?

It is actual suppliername and i have checked it many times to ensure i am spelling it correctly and it is correct.

Am i calling it correctly?

screenshot may be?

Post the values that are in


Yii::$post->request->post();




Array ( [_csrf] => QmJCY0ZmME0xUSsXKBF8AQgPJCQqHF8iFzAkWgsCdyEDUR0sP1NyEg== [Supplier] => Array ( [suppliercode] => mkl [suppliername] => [method] => 0 [notes] => ) ) 



That is the array from:




Yii::$app->request->post();



suppliername is empty so ->post(‘suppliername’) will be too.

Its suppliercode im after. it returns empty.

You’ll need to show the actual code that isn’t working.

I am trying to do this, when the form is submitted, if there is not currently a suppliercode it will return the form with the pre-entered suppliercode, at the minute it returns an empty form, unless it is a suppliercode in which the form is then entered with the correct details.




$model->suppliercode = Yii::$app->request->post('suppliercode');



I am trying to set the models suppliercode so when its passed back to the form, the $field will be populated with the inputted value.