formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.89k stars 1.06k forks source link

Render form with submission #5467

Closed martinbelcic closed 9 months ago

martinbelcic commented 9 months ago

I'm using formiojs@4.13.11. I'm trying to make a PDF out of the form displayed in my web page. But I am having issues because since Formio.createForm does not renders the submission initally, I am setting it afterwards, the first time the form is rendered it's entirely empty.

brendanbond commented 9 months ago

The createForm API can either take a form JSON definition or a Form.io form or submission URL. Here's an example of the former: https://formio.github.io/formio.js/app/examples/jsfiddle.html

The latter would look something like Formio.createForm(document.getElementById('formio'), 'https://<form.io server url>/project/<my project id>/form/<my form id>/submission/<my submission id>'); but you'd need to ensure that you have the correct access permissions.

martinbelcic commented 9 months ago

In the example you provided you are setting the submission inside the .then(), after the createForm promise is resolved. It has the same issue, the form will be empty on the first render

brendanbond commented 9 months ago

Right, the submission is always going to be injected at runtime when created like this

humble-codes commented 5 months ago

hey @brendanbond I am facing a different issues when rendering a form in edit mode. There is a trigger on a data-source resource which should trigger on form init ; but in edit mode, the trigger doesn't works unless and until I reload the same page.

Can you please guide a little bit ?