Javascript not working after mailing form PDF

PvN94

Member
If I have a form with email plugin with the option 'Attach as PDF' set to yes, and I save that form (and the email is sent), on the page loaded after that javascript does not work.
In the console I see an error 'Uncaught TypeError: cannot read property 'addEvent' of null' in form.js:2.
After refreshing the page or going to another page everything works as it should.
This is ONLY with the pdf attachment, as soon as that is set to 'No' everything works fine.

Any idea on what happens here?
 
I've put the link to the form in 'My site'. The form takes text displayed in the field and puts it in the calc, via AJAX update. When the form is saved it is emailed, with pdf, and you're redirected back to the form. This is when the error occurs, and when typing text in the field you can see it is not put into the calc element.
 
I've looked at this some more and it seems that the form isn't loaded in correctly. When 'this.form' is used it returns null and the js fails. The first error is on line 1640 in the code that seems to fade in/out repeatgroup buttons, but when commenting that bit out it just fails in other places where 'this.form' is used.
 
Hmmm. OK, I see the problem, but not entirely sure why it's happening. The 'block' it's building in the JS is a details rather than form view name, with a rowid (the newly created one) like details_3_123, instead of form_3.

This may be because we weren't resetting the view request variable properly after rendering the PDF. In order to render the PDF, we fake out a details view render (ie run the same code that loading a details view of the form would), which winds up resetting the model from being a form (during processing) view to a details view. And then we attempt to kind of set it back the way it was after rendering the PDF.

https://github.com/Fabrik/fabrik/commit/1cc89eaab1b957169c27ccdf8d52232ef052e41e

You can just edit that one file on your server if you want, rather than doing a complete github update.

But, given that you are doing a form redirect, I'm not entirely sure why that view AND the rowid are persisting across that redirect.

Anyway, try that fix ... but I think it'll still be broken, as I suspect it'll wind up with form_3_123 instead of just form_3.

Let me know.

-- hugh
 
I applied it, but it's still the same. Is there not some way you can clear everything and load the appropriate screen from scratch?
 
Well that's what I'm trying to figure out. In theory doing the redirect should do exactly that, but isn't. I spent an hour last night trying to figure it out, haven't worked out what's going on yet. I'll take a another look when I have some more time.

-- hugh
 
For what it's worth, I've been digging into the files a bit and in the email.php file it's $controller->display(); (line 506), this links to the FabrikControllerDetails in details.php where the problem is in $view->display(); (line 106).
I would assume this is calling view.pdf.php (in com_fabrik/views/form/) but that doesn't seem to be the case, so I'm a bit stuck now.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top