I'm working with this event dispatch: dispatchEvent('nextbits_form_save_after',array('form_data'=>$params, 'form_model'=>$formModel)); but I don't have any documentation on it.

The event fires after a contact form is submitted, and I need to do some routing to deliver the posted data to specific email addresses based on some of the choices on the form, etc. How can I get a listing or enumeration of the data that is passed with the event?

I was thinking something along the lines of:

$request = $observer->getEvent()->getData(‘form_data’);

and then

foreach ($request as $k => $v) $output .= "Key: '".$k."' | Value: ".$v."<br>";

...but I get no response from that....

  • put here your observer code... – Amit Bera Apr 10 '14 at 20:03
  • 1
    Haven't really put anything together yet. I need to pass the form information to an email recipient. And also need to route the email to an appropriate recipient based on the Country and/or State data submitted with the form. My problem is, I need to layout the data to construct the email message as well as code the logic to properly send the email...but I have no idea what data (or what it's called) is coming over with the event.... – Greg Nickoloff Apr 10 '14 at 20:15
  • Did you try $this->getRequest() and/or '$this->getRequest()->getParams()`? – pspahn Apr 10 '14 at 21:47
  • I did try $request = $observer->getEvent()->getRequest()->getParams(); and ` = $observer->getEvent()->getRequest()`, but don't seem to get anything back. – Greg Nickoloff Apr 11 '14 at 13:10
  • Just tried this: $event = $observer->getEvent(); $formData = $event->getFormData(); // magic get/set $formModel = $event->getFormModel(); // magic get/set $fd = zend_debug::dump($formData); $fm = zend_debug::dump($formModel); – Greg Nickoloff Apr 11 '14 at 13:28

The request object is not part of the observer object. So (i believe) the only solution to get to this data is to use Mage::app()->getRequest() from within your flow to get the request object. From there on you probably know the rest of the way with getParams() etc.

  • Thanks... I must not be doing it right. $observer = Mage::app()->getRequest(); $request = $observer->getEvent()->getData(‘form_data’); foreach ($request as $k => $v) $Body .= "Key: '".$k."' | Value: ".$v."<br>"; ...no output at all. – Greg Nickoloff Apr 14 '14 at 13:32
  • 1
    Yes, you're doing it wrong unfortunately. Try doing the following $request = Mage::app()->getRequest() and then $request->getData() contains all your needed data. Currently you are mixing the request syntax with observer type syntax, hence it does not work. If this solves your issues, please mark this answer as the correct one. – Tim Hofman Apr 14 '14 at 15:28
  • Yes! This works: $event = $observer->getEvent(); $formData = $event->getFormData(); $formModel = $event->getFormModel(); echo "<pre>"; print_R($formData); print_R($formModel); for what I need. Thank you @Tim – Greg Nickoloff Apr 16 '14 at 14:34
  • Superb, good to hear! – Tim Hofman Apr 16 '14 at 14:57

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.