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.
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
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.
Offline
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
$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
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
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):
$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
Offline
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
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:
$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
Offline
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:
$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
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?
Offline
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
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.
Offline
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):
$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);}
Offline
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