Passing data to controller from form is not working

Hi , in the _form.php data i have this:

<?= $form->field($model, ‘email’)->textInput([‘maxlength’ => 45]) ?>

This is from Person model , so i want that value from input to get in my controller, i try this :

print_r($_POST);

exit();

But it return empty array.

Any help please.

Hi mcirkova!

Could you please post your view and controller? that way it’s gonna be easy to help you.

ps: Don’t forget to use the code snippet.

Best regards,

Ricardo

Hi,

you can’t display things from controller. it is the View role.

The better way to test whether a form has been submitted is a condition in the controllet i think. But your controller and View code will tell more!

It will work at any case.




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



I am not clear about why $_POST is not working, But it may be due to your config.

check it.

Are you sure your form button does a submit?

Try to check what is sent to the server at browser level, like using firebug extension.