- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
<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
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Magento 2 Blogs/Tutorial
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Magento 2 Blogs/Tutorial
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Form submit and save
Thank you mate,
that helped a lot
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Form submit and save
What about saving data?