I want to have 2 different forms according to customer group, so how to do so? And how to call a controller in form:

                <form method="POST">
                    <input type="radio" name="type_profile" value="local" checked> Client Local<br>
                    <input type="radio" name="type_profile" value="export"> Client Export<br>
                    <input type="submit" name="submit" value="create new account " />
                if (isset($_POST['submit'])) {
                        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
                        $redirect = $objectManager->get('\Magento\Framework\App\Response\Http');

                        if($_POST['type_profile']=="local") {
                            //echo "You have selected : local";
                        }else if($_POST['type_profile']=="export") {
                            //echo "You have selected :export";


1 Answer 1


Call controller in form.

  1. Add Form tag like this in phtml file:

    <form action="<?php echo $block->getFormAction() ?>" method="post">
  2. Add function in block file like this:

    public function getFormAction()
      return '/companymodule/controller_name/action'

For more details you can refer to this link: How to Create Custom Form in Magento2

  • thanks it seems to be helpfull t will test that Oct 22, 2018 at 13:54
  • just one question how to do to enable customer from groups2 to register from this form is there something extra to do when creating the new form Oct 22, 2018 at 13:55
  • nothing happened so can you please explain more what to put in getFormAction and how to call the inscription form Oct 22, 2018 at 14:13
  • You need to open your block file then add new function like getFormAction() in that you have to return your action path like this (/your module/controller_name/action) Oct 22, 2018 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.