Forums

Creating a PDF out of form data

klimmbimm 19 Aug, 2010
Hi there!

I just installed ChronoForms the first time, because I read on the internet that it is a very flexible form creator.
My aim is a) to store the data from the form in a database and b) load this data into a PDF form and send the PDF as an attachment to a fixed email address.
Is it possible to do this with existing plugins? Or do I have to program this by myself?
What would be the best way to start? How to add my own code to ChronoForms?

I'm new at Joomla and not a big PHP pro. I'm looking forward to reading your replies.

Thanks in advance!

Regards,

KB
GreyHead 19 Aug, 2010
Hi KB,

a) is pretty simple - please check the Database tutorial from the Tutorials link above.

b) will need some coding by you, it's not built in. There are several threads here that talk about putting form data into PDFs.

c) You can add your own code to ChronoForms in several ways dependign on what it needs to do. Most code that goes with the form display you can put into the Form HTML box; most code to do with form processing goes into one of the OnSubmit code boxes.

Bob
klimmbimm 24 Aug, 2010
Thank you for your help GreyHead!

I searched the forum for a tutorial generating a PDFs out of ChronoForms, but the results on the first few sites were all hints, that the problem was discussed several times before.
Isn't there a finished tutorial for PDFs or maybe someone, who shares his code?
GreyHead 24 Aug, 2010
Hi klimmbimm,

Sorry, there is no tutorial that I remember seeing.

Bob
GreyHead 31 Aug, 2010
Hi klimmbimm,

Sorry, no. That project went in another direction and I never went back to it. If I remember correctly a couple of other people have posted here about ways to do this though.

Bob
klimmbimm 06 Sep, 2010
for adding a generated (PDF-)file is it really necessary to:
a) set email attachments to "yes" (under "choose email(s) settings" -> "properties")
b) set "enable uploads" to "yes" (under file uploads)
c) add some line of code under "form code" -> "on submit code - before sending email" *)
... or could i leave out one of the steps?

btw: this solution works for me, but i'm still trying to understand the whole process because i am to create several forms with this functionality.
GreyHead 06 Sep, 2010
Hi klimmbimm,

I don't think that you need 'Enable Uploads' unless you are uploading files from your form.

Bob
klimmbimm 06 Sep, 2010
thanks you for the quick answer!

there appeared some other questions:
1.) what does $chronofile['name'] do (i couldn't "echo" it)? is it the file-ending (in my case .pdf)?
2.) is it possible to deactivate the "submit" button after the first press? the pdf buildiung process and the email sending takes while and i want to avoid multiple clicks.
GreyHead 06 Sep, 2010
Hi klimmbimm,

1) It's the name of the uploaded file

2) Yes, you can do that with JavaScrip. From memory the code is
$('submit').addEvent('submit', function() {
    $('submit').disabled = true;
});
This should work provided that your submit button has id='submit'

Bob
klimmbimm 06 Sep, 2010

$('submit').addEvent('submit', function() {
    $('submit').disabled = true;
});



I tried this, but this didn't work. The form cannot load: Parse error: syntax error, unexpected '(', expecting T_VARIABLE or '$' in C:\xampp\htdocs\joomla\components\com_chronocontact\chronocontact.html.php(180) : eval()'d code on line 34

Further I tried your solution from this post:
<?php
$script = "
window.addEvent('domready', function() {
  $('submit').addEvent('click', function() {
    $('submit').disable = true;
  });
});
";
$doc = & JFactory::getDocument();
$doc->addScriptDeclaration($script);
?>

... but unfortunately I am still able to click multiple times.


my button is this (i added id="submit" on purpose):
<div class="form_item">
  <div class="form_element cf_button">
    <input value="Absenden" name="submit" type="submit" id="submit"/>
  </div>
  <div class="cfclear"> </div>
</div>
klimmbimm 06 Sep, 2010
ok, i added a "d" on line 5:

<?php
$script = "
window.addEvent('domready', function() {
  $('submit').addEvent('click', function() {
    $('submit').disabled = true;
  });
});
";
$doc = & JFactory::getDocument();
$doc->addScriptDeclaration($script);
?>

now the button is disabled after the first click. but the form won't submit anymore.

i also tried it with line 4 changed this way:
 $('submit').addEvent('submit', function() {

but this won't work either. probably the script waits for the submitted form - but this is what lasts too long.

any idea what i did wrong?
GreyHead 06 Sep, 2010
Hi klimmbimm,

Hmmm you could try setting the style to display:none ???

Bob
klimmbimm 06 Sep, 2010
du you mean like:
<?php
$script = "
window.addEvent('domready', function() {
  $('submit').addEvent('click', function() {
    $('submit').display = none;
  });
});
";
$doc = & JFactory::getDocument();
$doc->addScriptDeclaration($script);
?>


this doesn't work...
GreyHead 06 Sep, 2010
Hi klimmbimm,

I think it would be
$('submit').setStyle('display', 'none');


Bob
klimmbimm 07 Sep, 2010

$('submit').setStyle('display', 'none');



1.) That works! Thank you!
a) But... the form still submits several times, if I abuse the Enter-Button. Is there a similar solution for that?
b) And how could I display a message like "Please wait while your information is being sent..."?

2.) Do you think, it would be a useful improvement to ChronoForms, if the wizard-generated code would create an id-attribute for each element in the form? The advantage would be, that I could refer to this id in the "Form JavaScript"-field and don't have to change the form manually again, if I had used the wizard-edit before.
GreyHead 07 Sep, 2010
Hi klimmbimm,

Well, the 'disabled' versions would sort the 'Enter' button problem if you could get one to work. Maybe Google would turn up a better solution. Using 'onClick' won't work as you've seen it blocks the validation, 'onSubmit' seems to be the right event but isn't fast enough. I'm not sure what else might work.

I agree about the ids.

Bob
klimmbimm 07 Sep, 2010
is it possible to submit the form only with javascript? then i would be able to use the "button-disabled" solution.
like this:

<?php
$script = "
window.addEvent('domready', function() {
  $('submit').addEvent('click', function() {
    $('ChronoContact_myForm').send();
    $('submit').disabled = true;
    $('submit').value = 'Sending... please wait.';
  });
});
";
$doc = & JFactory::getDocument();
$doc->addScriptDeclaration($script);
?>
GreyHead 07 Sep, 2010
Hi klimmbimm,

Yes - theoretically at least. You'd need to make sure that the validation was still triggered.

And users without JavaScript might have a problem so you'd need to make sure that the form worked for them too.

Bob
klimmbimm 17 Sep, 2010

Yes - theoretically at least. You'd need to make sure that the validation was still triggered.
And users without JavaScript might have a problem so you'd need to make sure that the form worked for them too.



...and with the so solution posted above [$('ChronoContact_myForm').send();], it won't lead me to the next page.

btw: i found the solution for sending the form on http://solutoire.com/2007/09/10/submitting-forms-asynchronously-using-mootools/
This topic is locked and no more replies can be posted.