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
samdark
(Alexander Makarov)
June 9, 2014, 2:30pm
2
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?
alex-w
(Pr0j3ct A1ex)
June 10, 2014, 8:32am
5
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();
alex-w
(Pr0j3ct A1ex)
June 10, 2014, 9:02am
7
suppliername is empty so ->post(‘suppliername’) will be too.
Its suppliercode im after. it returns empty.
alex-w
(Pr0j3ct A1ex)
June 10, 2014, 9:16am
9
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.