0

I am building an module and need to process a form but am having troubles getting the variables to POST and am just redirected to the same page. The form looks like this :

    <form id="orderapproval-item-form" class="orderapproval-hidden" action="<?php echo $this->getUrl('orderapproval/customercart/remarksdecline');?>" method="post">
  <?php echo $this->getBlockHtml('formkey'); ?>
    <input type="text" name="message" class="orderapproval-disabled" value="<?php echo $this->__('Enter decline reason'); ?>" />
    <input type="submit" value="<?php echo $this->__('Decline'); ?>" />
  </form>

i have controller

    public function remarksdeclineAction()
{

              $message = $this->getRequest()->getParam('message');

              echo $message;
          echo "hi";
           exit();    
    }

now how to insert form value in table. anyone can help me

  • @Qaisar Satti .. thanks for editing my question can you reply – Sarvesh Tiwari Dec 27 '16 at 11:23
0
public function remarksdeclineAction()
{
             $model = Mage::getModel('OrderApproval/process');
             $message = $this->getRequest()->getParam('message');
             $model->setMessage($message); //your table column name will be mmessage
             $model->save();

              echo $message;
          echo "hi";
           exit();    
    }

read this how models work

http://devdocs.magento.com/guides/m1x/magefordev/mage-for-dev-5.html https://www.pierrefay.com/en/magento-training/model-database-tutorial.html

  • $model->setMessage($message); $message is my table column name – Sarvesh Tiwari Dec 27 '16 at 11:32
  • setMessage in Message column name should be message . ` $message` will be value – Qaisar Satti Dec 27 '16 at 11:34
  • sorry i did not get you setItemcomment($message) where itemcomment is column am i right – Sarvesh Tiwari Dec 27 '16 at 11:40
  • First letter will be capital of columm after set – Qaisar Satti Dec 27 '16 at 12:07
  • now i am using this function public function remarksdeclineAction() { $model = Mage::getSingleton('OrderApproval/process'); $message = $this->getRequest()->getParam('message'); $model->setItemcomment( $this->getRequest()->getPost() ); $model->save(); echo $message; echo "hi"; exit(); } – Sarvesh Tiwari Dec 27 '16 at 12:12
0
<form id="orderapproval-item-form" class="orderapproval-hidden" action="<?php echo Mage::helper->getUrl("orderapproval/customercart/remarksdecline/");?>" method="post">
    <?php echo $this->getBlockHtml('formkey'); ?>
    <input type="text" name="message" class="orderapproval-disabled" value="<?php echo $this->__('Enter decline reason'); ?>" />
    <input type="submit" value="<?php echo $this->__('Decline'); ?>" />
</form>

Please check your redirection url in form action. add just need to set url in small char.

Thanks

  • now i put form url in small char but its still not working <?php echo Mage::helper->getUrl("orderapproval/customercart/remarksdecline");?> – Sarvesh Tiwari Dec 27 '16 at 11:32
  • your controller call or not?? – Ajay Patel Dec 27 '16 at 11:53
  • no controller is not calling – Sarvesh Tiwari Dec 27 '16 at 11:55
  • <?php echo Mage::helper->getUrl("orderapproval/customercart/remarksdecline/");?> print this line – Ajay Patel Dec 27 '16 at 12:05
  • did not anything – Sarvesh Tiwari Dec 27 '16 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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