cancel
Showing results for 
Search instead for 
Did you mean: 

Form submit and save

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Form submit and save

<form class="form" id="perguntas-form" action="<?php echo $this->getUrl("hello/index/index")?>" method="post" autocomplete="off">

Hey guys,

I have this on my form on:

hello\view\adminhtml\templates\biperguntas_index_index.phtml 

 

Im trying to get the post values from the form on:

Hello\Controller\Adminhtml\Index\Index.php

 

Why is this not working?

Thanks

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Form submit and save

Hi @AlexMesquita

 

Seems like you are missing formkey to pass.

 

below is the code to pass the formkey to controller !

 

<input name="form_key" type="hidden" value="<?php /* @escapeNotVerified */ echo $block->getFormKey(); ?>" />

After passing formkey , check in your controller you will able to get the post values over there !!

 

In your controller get post value like below : 

 

$PostValue = $this->getRequest()->getPost();
print_r($PostValue);

 

Hope it helps 

if issue solved,Click Kudos & Accept as Solution

View solution in original post

Re: Form submit and save

You can  get form post value using controller by below way,

$getPost = $this->getRequest()->getPost();
var_dump($getPost);

Using above way you can get array of your form data in controller.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

View solution in original post

4 REPLIES 4

Re: Form submit and save

Hi @AlexMesquita

 

Seems like you are missing formkey to pass.

 

below is the code to pass the formkey to controller !

 

<input name="form_key" type="hidden" value="<?php /* @escapeNotVerified */ echo $block->getFormKey(); ?>" />

After passing formkey , check in your controller you will able to get the post values over there !!

 

In your controller get post value like below : 

 

$PostValue = $this->getRequest()->getPost();
print_r($PostValue);

 

Hope it helps 

if issue solved,Click Kudos & Accept as Solution

Re: Form submit and save

You can  get form post value using controller by below way,

$getPost = $this->getRequest()->getPost();
var_dump($getPost);

Using above way you can get array of your form data in controller.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Form submit and save

Thank you mate,

that helped a lot

Re: Form submit and save

What about saving data?