Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 10-14-2017 18:54:23

sppars
Member
Registered: 01-25-2006
Posts: 301

Dynamic Form to Email and Post to File

I would like to have a dynamic form that will email the form data but also post to a php file that will generate a pdf file.

I already have the php file with the pdf working. And also have the dynamic form working separately. Now I just would like to get the form data from the dynamic form passed to the php file.

Is there a way to do this?

Thanks.

Offline

 

#2 10-16-2017 09:27:29

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19861
Website

Re: Dynamic Form to Email and Post to File

Place a hook for your PDF generation code into the dynform_proc() function in the {private}/apps/cms/CMS_DynForm/CMS_DynForm.php class.  Somewhere just above the comment 'Make the message' would be a good spot.  The $return array has everything you need in it, and you can check $ref to be sure you only process your PDF file code for a particular form id.


Nick Hendler

Offline

 

#3 10-18-2017 18:54:24

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Dynamic Form to Email and Post to File

Nick,

Thank you for pointing me in the right direction. I was able to get this to work, however, I had to create an array to store the cgi values, since the result array only held the default database values (or was I possibly looking at the wrong array?).

My ultimate goal was to get this dynamic form into the product offer page. I added the dynamic form into prodshow.php using the include namespace

Code:

$this->include_namespace('cms','dynform','formid');

It errors and says "The resource you requested cannot be found. Please use the menu to continue." I think the problem is the $ref name, because if the product offer has the same name as the dynamic form, it works.

Any work around or ideas to make this work?

Thanks.

Offline

 

#4 10-19-2017 07:50:47

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19861
Website

Re: Dynamic Form to Email and Post to File

'formid' is not the id of a dynamic form you've built.  You want to put the id of an actual form in there.


Nick Hendler

Offline

 

#5 10-19-2017 09:18:51

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Dynamic Form to Email and Post to File

Nick, I just wrote formid as an example. The actual code has the actual form id in there. Any ideas what could be happening?

Offline

 

#6 10-20-2017 08:02:39

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19861
Website

Re: Dynamic Form to Email and Post to File

Sorry.  I just realized that namespace does not take the formid on input, it's got to be globalized as core.ref first.  Do this (commented heavy):

Code:

$temp_coreref = $this->globals('core.ref'); // Get the current core.ref into a variable
$this->globals('core.ref','formid'); // Set core.ref to your formid
$this->include_namespace('cms','dynform'); // Execute the namespace without parameters
$this->globals('core.ref',$temp_coreref); // Set core.ref back to it's original value

Nick Hendler

Offline

 

#7 10-20-2017 20:28:23

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Dynamic Form to Email and Post to File

Nick,

I tried the code. It gets the form displayed into the product offer, but when you come to submit the form it goes to the 404 page and says the resource you requested can not be found,

I believe it's because core.ref is being changed only for the dynform_disp function and when the function dynform_proc is running it's resorting back to the original core.ref. Could that be the case? If so, what would I need to do, to pass the correct ref value to the dynform_proc function?

Offline

 

#8 10-23-2017 08:06:50

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19861
Website

Re: Dynamic Form to Email and Post to File

Sorry, missed something.  This would have worked within the CMS app like on a webpage, but not in the ECOM app in a product offer.  Basically due to the application running.  To correct, do:

Code:

$temp_coreref = $this->globals('core.ref'); // Get the current core.ref into a variable
$temp_coreapp = $this->globals('core.app'); // Get the current core.app into a variable
$this->globals('core.ref','formid');        // Set core.ref to your formid
$this->globals('core.app','cms');           // Set core.app to cms
$this->include_namespace('cms','dynform');  // Execute the namespace without parameters
$this->globals('core.ref',$temp_coreref);   // Set core.ref back to it's original value
$this->globals('core.app',$temp_coreapp);   // Set core.app back to it's original value

Nick Hendler

Offline

 

#9 10-23-2017 21:03:39

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Dynamic Form to Email and Post to File

Nick,

Still failed to work on submit.

As a trial and error, I also tried resetting the namespace to both 'display' and 'dynform', but neither of those attempts worked:

Code:

$temp_coreref = $this->globals('core.ref'); // Get the current core.ref into a variable
$temp_coreapp = $this->globals('core.app'); // Get the current core.app into a variable
$temp_corens = $this->globals('core.namespace');  // Get the current core.ns into a variable
$this->globals('core.ref','formid');        // Set core.ref to your formid
$this->globals('core.app','cms');           // Set core.app to cms
$this->globals('core.namespace','dynform'); // Set core.ns to dynform
$this->include_namespace('cms','dynform');  // Execute the namespace without parameters
$this->globals('core.ref',$temp_coreref);   // Set core.ref back to it's original value
$this->globals('core.app',$temp_coreapp);   // Set core.app back to it's original value
$this->globals('core.namespace',$temp_corens);   // Set core.ns back to it's original value

When we do this, aren't the values only changing when the form is being printed and then being reverted back to the original values for the rest of the prodshow... or are the values staying at the temp values until the form is submitted too?

Offline

 

#10 10-24-2017 08:24:10

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19861
Website

Re: Dynamic Form to Email and Post to File

What you're doing there is getting some global variables and saving them as temporary variables, executing the cms.dynform namespace, then setting those globals right back to their original value.  This does not affect anything but what we're looking at here. 

So the form gets printed.  But when you submit the form, you say it fails.  How?  Can you share a URL?


Nick Hendler

Offline

 

#11 10-24-2017 20:28:03

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Dynamic Form to Email and Post to File

Nick,

Site is still a work in progress, but I have the dynamic form on the  (under the Specify Product accordion) and on a .

The form is the same and the only difference is the form is being called upon on the product offer page per your instructions here. On the webpage, the form is doing exactly what I need it to do - email the form data and generate PDF in a new window. On the product offer, form gets displayed but errors to 404 page on submit and nothing is emailed.

Same thing happens on a regular dynamic form (i.e. non-pdf generating).

Offline

 

#12 10-25-2017 05:17:34

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1716

Re: Dynamic Form to Email and Post to File

one difference between the two forms is the ref value.
Product page = Tin-Ceiling-Panel-Design-200
Form only page = PDFspecifytin

If you have written a function looking for PDFspecifytin as the ref, you may be able to resolve the problem.


Rob

Offline

 

#13 10-25-2017 08:45:20

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19861
Website

Re: Dynamic Form to Email and Post to File

I see the issue.  The 'ref' in the form is being set to the ref of the product due to a CGI global.  Do this (I used an array here to store/reset variable values to simplify it):

Code:

$vars = array('core.ref' => '', 'core_cgi.ref' => '', 'core.app' => '', 'core_display.metatitle' => '', 'core_display.metakeywords' => '', 'core_display.metadesc' => '', 'core.ref_disp' => '');
foreach ($vars as $varid => $varval) {$vars[$varid] = $this->globals($varid);}

$this->globals('core.ref','formid');        // Set core.ref to your formid
$this->globals('core_cgi.ref','formid');    // Set core_cgi.ref to your formid
$this->globals('core.app','cms');           // Set core.app to cms
$this->include_namespace('cms','dynform');  // Execute the namespace without parameters

foreach ($vars as $varid => $varval) {$this->globals($varid,$varval);}

Nick Hendler

Offline

 

#14 10-25-2017 19:01:29

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Dynamic Form to Email and Post to File

Awesome! That did the trick.

So I guess that means the only reason the webpage was working was because I set the test webpage ref identical to the dynamic form ref.

Thanks Nick and Zanart!

Offline

 

#15 10-26-2017 08:21:13

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19861
Website

Re: Dynamic Form to Email and Post to File

So I guess that means the only reason the webpage was working was because I set the test webpage ref identical to the dynamic form ref.

Exactly.


Nick Hendler

Offline

 

Board footer