How to call controller method from another controller?Exclude a specific categoryhow to override a Core...

How to access internet and run apt-get through a middle server?

Does it take energy to move something in a circle?

Not a Long-Winded Riddle

Does an Eldritch Knight's Weapon Bond protect him from losing his weapon to a Telekinesis spell?

Calculate of total length of edges in Voronoi diagram

Microtypography protrusion with Polish quotation marks

Can we "borrow" our answers to populate our own websites?

Prioritising polygons in QGIS

Why zero tolerance on nudity in space?

What is the difference between "...", '...', $'...', and $"..." quotes?

Does diversity provide anything that meritocracy does not?

What game did these black and yellow dice come from?

What is the industry term for house wiring diagrams?

Buying a "Used" Router

What to do with threats of blacklisting?

Does the US government have any planning in place to ensure there's no shortages of food, fuel, steel and other commodities?

Do authors have to be politically correct in article-writing?

If angels and devils are the same species, why would their mortal offspring appear physically different?

Is a new boolean field better than null reference when a value can be meaningfully absent?

Why do all the books in Game of Thrones library have their covers facing the back of the shelf?

Why do we have to make "peinlich" start with a capital letter and also end with -s in this sentence?

What makes papers publishable in top-tier journals?

Potential client has a problematic employee I can't work with

Coworker asking me to not bring cakes due to self control issue. What should I do?



How to call controller method from another controller?


Exclude a specific categoryhow to override a Core Customer Model in a local module in magento 1.9.2Shopping cart is empty after cancel the payment in magento-1.9.1.1how to reset password for 15000 user and send it to the email id in magento 1.9Magento1 createBlock method returns “bool(false)” in livehostHow to use non class file and call Actions magento1.9?Error start SessionGet Shipment Id while creating Shipment in Magento 1.9How to resolve Call to a member function getTelephone() for guest user login magento 1.9.1.0?Magento 1.9.2.4 Custom Captcha not displaying













1















Created a model in which the form validation on the beck



  public function validation_form()
{
$error = false;
if (!Zend_Validate::is($name, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Name is required');
}
if (!Zend_Validate::is($message, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Message is required');
}
if (!Zend_Validate::is($subject, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Subject is required');
}
if (!Zend_Validate::is($email, 'EmailAddress')) {
$error = Mage::getSingleton('core/session')->addError('Email is required');
}
if ($error) {
throw new Exception();
}
}


And there is a method in the controller that adds data to the database.



 public function postAction()
{
$post = $this->getRequest()->getPost();
if ($post) {

$name = $this->getRequest()->getPost('name');
$email = (string)$this->getRequest()->getPost('email');
$phone = $this->getRequest()->getPost('phone');
$user_agent = Mage::helper('core/http')->getHttpUserAgent();
$remote_ip = Mage::helper('core/http')->getRemoteAddr();
$subject = $this->getRequest()->getPost('subject');
$other_subject = $this->getRequest()->getPost('other');
$message = $this->getRequest()->getPost('message');
$created_at = Mage::getModel('core/date')->date('Y-m-d H:i:s');
etc...


How to connect function postAction() to validation so that the variables "$name, $email, etc..." are available in the validation model.



Path to the controller mymodul/feedback/controllers/IndexController.php



Path to the validation mymodul/feedback/model/Validation.php










share|improve this question









New contributor




Рома Лытарь is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1















    Created a model in which the form validation on the beck



      public function validation_form()
    {
    $error = false;
    if (!Zend_Validate::is($name, 'NotEmpty')) {
    $error = Mage::getSingleton('core/session')->addError('Name is required');
    }
    if (!Zend_Validate::is($message, 'NotEmpty')) {
    $error = Mage::getSingleton('core/session')->addError('Message is required');
    }
    if (!Zend_Validate::is($subject, 'NotEmpty')) {
    $error = Mage::getSingleton('core/session')->addError('Subject is required');
    }
    if (!Zend_Validate::is($email, 'EmailAddress')) {
    $error = Mage::getSingleton('core/session')->addError('Email is required');
    }
    if ($error) {
    throw new Exception();
    }
    }


    And there is a method in the controller that adds data to the database.



     public function postAction()
    {
    $post = $this->getRequest()->getPost();
    if ($post) {

    $name = $this->getRequest()->getPost('name');
    $email = (string)$this->getRequest()->getPost('email');
    $phone = $this->getRequest()->getPost('phone');
    $user_agent = Mage::helper('core/http')->getHttpUserAgent();
    $remote_ip = Mage::helper('core/http')->getRemoteAddr();
    $subject = $this->getRequest()->getPost('subject');
    $other_subject = $this->getRequest()->getPost('other');
    $message = $this->getRequest()->getPost('message');
    $created_at = Mage::getModel('core/date')->date('Y-m-d H:i:s');
    etc...


    How to connect function postAction() to validation so that the variables "$name, $email, etc..." are available in the validation model.



    Path to the controller mymodul/feedback/controllers/IndexController.php



    Path to the validation mymodul/feedback/model/Validation.php










    share|improve this question









    New contributor




    Рома Лытарь is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1








      Created a model in which the form validation on the beck



        public function validation_form()
      {
      $error = false;
      if (!Zend_Validate::is($name, 'NotEmpty')) {
      $error = Mage::getSingleton('core/session')->addError('Name is required');
      }
      if (!Zend_Validate::is($message, 'NotEmpty')) {
      $error = Mage::getSingleton('core/session')->addError('Message is required');
      }
      if (!Zend_Validate::is($subject, 'NotEmpty')) {
      $error = Mage::getSingleton('core/session')->addError('Subject is required');
      }
      if (!Zend_Validate::is($email, 'EmailAddress')) {
      $error = Mage::getSingleton('core/session')->addError('Email is required');
      }
      if ($error) {
      throw new Exception();
      }
      }


      And there is a method in the controller that adds data to the database.



       public function postAction()
      {
      $post = $this->getRequest()->getPost();
      if ($post) {

      $name = $this->getRequest()->getPost('name');
      $email = (string)$this->getRequest()->getPost('email');
      $phone = $this->getRequest()->getPost('phone');
      $user_agent = Mage::helper('core/http')->getHttpUserAgent();
      $remote_ip = Mage::helper('core/http')->getRemoteAddr();
      $subject = $this->getRequest()->getPost('subject');
      $other_subject = $this->getRequest()->getPost('other');
      $message = $this->getRequest()->getPost('message');
      $created_at = Mage::getModel('core/date')->date('Y-m-d H:i:s');
      etc...


      How to connect function postAction() to validation so that the variables "$name, $email, etc..." are available in the validation model.



      Path to the controller mymodul/feedback/controllers/IndexController.php



      Path to the validation mymodul/feedback/model/Validation.php










      share|improve this question









      New contributor




      Рома Лытарь is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      Created a model in which the form validation on the beck



        public function validation_form()
      {
      $error = false;
      if (!Zend_Validate::is($name, 'NotEmpty')) {
      $error = Mage::getSingleton('core/session')->addError('Name is required');
      }
      if (!Zend_Validate::is($message, 'NotEmpty')) {
      $error = Mage::getSingleton('core/session')->addError('Message is required');
      }
      if (!Zend_Validate::is($subject, 'NotEmpty')) {
      $error = Mage::getSingleton('core/session')->addError('Subject is required');
      }
      if (!Zend_Validate::is($email, 'EmailAddress')) {
      $error = Mage::getSingleton('core/session')->addError('Email is required');
      }
      if ($error) {
      throw new Exception();
      }
      }


      And there is a method in the controller that adds data to the database.



       public function postAction()
      {
      $post = $this->getRequest()->getPost();
      if ($post) {

      $name = $this->getRequest()->getPost('name');
      $email = (string)$this->getRequest()->getPost('email');
      $phone = $this->getRequest()->getPost('phone');
      $user_agent = Mage::helper('core/http')->getHttpUserAgent();
      $remote_ip = Mage::helper('core/http')->getRemoteAddr();
      $subject = $this->getRequest()->getPost('subject');
      $other_subject = $this->getRequest()->getPost('other');
      $message = $this->getRequest()->getPost('message');
      $created_at = Mage::getModel('core/date')->date('Y-m-d H:i:s');
      etc...


      How to connect function postAction() to validation so that the variables "$name, $email, etc..." are available in the validation model.



      Path to the controller mymodul/feedback/controllers/IndexController.php



      Path to the validation mymodul/feedback/model/Validation.php







      magento-1.9






      share|improve this question









      New contributor




      Рома Лытарь is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Рома Лытарь is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 4 hours ago







      Рома Лытарь













      New contributor




      Рома Лытарь is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 21 hours ago









      Рома ЛытарьРома Лытарь

      325




      325




      New contributor




      Рома Лытарь is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Рома Лытарь is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Рома Лытарь is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          1














          I see several issues here:




          1. your method validation_form() does not take any parameters. It should be something like public function validation_form($name, $message, $subject, $email). Else, the method does not have access to any of the values from postAction().


          2. I don't knot if you can throw an Exception() with an empty message, and I'm not sure if the validate_form() method will work as expected, but you can try and open another question if new errors occur :)


          3. From your postAction(), call the method like this:



          Mage::getModel('mymodule/validation')->validate_form($name, $message, $subject, $email);



          ...assuming you defined your model namespace in your config.xml file. If you didn't, search for a tutorial how to define a basic Magento 1 module - it's easy ;)






          share|improve this answer
























          • Thanks, passed the values to the function and it all worked, thanks again)

            – Рома Лытарь
            21 hours ago











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Рома Лытарь is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f263333%2fhow-to-call-controller-method-from-another-controller%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I see several issues here:




          1. your method validation_form() does not take any parameters. It should be something like public function validation_form($name, $message, $subject, $email). Else, the method does not have access to any of the values from postAction().


          2. I don't knot if you can throw an Exception() with an empty message, and I'm not sure if the validate_form() method will work as expected, but you can try and open another question if new errors occur :)


          3. From your postAction(), call the method like this:



          Mage::getModel('mymodule/validation')->validate_form($name, $message, $subject, $email);



          ...assuming you defined your model namespace in your config.xml file. If you didn't, search for a tutorial how to define a basic Magento 1 module - it's easy ;)






          share|improve this answer
























          • Thanks, passed the values to the function and it all worked, thanks again)

            – Рома Лытарь
            21 hours ago
















          1














          I see several issues here:




          1. your method validation_form() does not take any parameters. It should be something like public function validation_form($name, $message, $subject, $email). Else, the method does not have access to any of the values from postAction().


          2. I don't knot if you can throw an Exception() with an empty message, and I'm not sure if the validate_form() method will work as expected, but you can try and open another question if new errors occur :)


          3. From your postAction(), call the method like this:



          Mage::getModel('mymodule/validation')->validate_form($name, $message, $subject, $email);



          ...assuming you defined your model namespace in your config.xml file. If you didn't, search for a tutorial how to define a basic Magento 1 module - it's easy ;)






          share|improve this answer
























          • Thanks, passed the values to the function and it all worked, thanks again)

            – Рома Лытарь
            21 hours ago














          1












          1








          1







          I see several issues here:




          1. your method validation_form() does not take any parameters. It should be something like public function validation_form($name, $message, $subject, $email). Else, the method does not have access to any of the values from postAction().


          2. I don't knot if you can throw an Exception() with an empty message, and I'm not sure if the validate_form() method will work as expected, but you can try and open another question if new errors occur :)


          3. From your postAction(), call the method like this:



          Mage::getModel('mymodule/validation')->validate_form($name, $message, $subject, $email);



          ...assuming you defined your model namespace in your config.xml file. If you didn't, search for a tutorial how to define a basic Magento 1 module - it's easy ;)






          share|improve this answer













          I see several issues here:




          1. your method validation_form() does not take any parameters. It should be something like public function validation_form($name, $message, $subject, $email). Else, the method does not have access to any of the values from postAction().


          2. I don't knot if you can throw an Exception() with an empty message, and I'm not sure if the validate_form() method will work as expected, but you can try and open another question if new errors occur :)


          3. From your postAction(), call the method like this:



          Mage::getModel('mymodule/validation')->validate_form($name, $message, $subject, $email);



          ...assuming you defined your model namespace in your config.xml file. If you didn't, search for a tutorial how to define a basic Magento 1 module - it's easy ;)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 21 hours ago









          simonthesorcerersimonthesorcerer

          3,53721127




          3,53721127













          • Thanks, passed the values to the function and it all worked, thanks again)

            – Рома Лытарь
            21 hours ago



















          • Thanks, passed the values to the function and it all worked, thanks again)

            – Рома Лытарь
            21 hours ago

















          Thanks, passed the values to the function and it all worked, thanks again)

          – Рома Лытарь
          21 hours ago





          Thanks, passed the values to the function and it all worked, thanks again)

          – Рома Лытарь
          21 hours ago










          Рома Лытарь is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Рома Лытарь is a new contributor. Be nice, and check out our Code of Conduct.













          Рома Лытарь is a new contributor. Be nice, and check out our Code of Conduct.












          Рома Лытарь is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f263333%2fhow-to-call-controller-method-from-another-controller%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

          How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

          變成蝙蝠會怎樣? 參考資料 外部連結 导航菜单Thomas Nagel, "What is it like to be a...