formio / ngFormBuilder

The Form.IO Form Builder Application
http://formio.github.io/ngFormBuilder/
MIT License
131 stars 130 forks source link

[QUESTION] How to prevent request to form.io API (api.form.io/form)? #453

Open vkvisli opened 4 years ago

vkvisli commented 4 years ago

Hi,

I am using the <form-builder/> directive in my application and would like to store the produced form schema in my own back-end database. However, when loading the application, the form builder sends a request to the form.io API (api.form.io/form). How can I prevent the form builder from sending this request?

This is currently how I have embedded the directive:

<form-builder form="vm.formSchema"/>

where formSchema refers to a property in my controller that holds the form schema object. I have experimented with the various scope attributes of the directive (e.g. src, url, options.noSource), but I can't seem to understand how to do it correctly without any documentation of these attributes.

Hope someone can help me with this, thanks :)

travist commented 4 years ago

It should not be sending requests to the API if you just set just the form JSON, so this would require further investigation. Is it possible to create a JSFiddle showing the issue and that would expedite our investigation?

vkvisli commented 4 years ago

Actually, I can refer to the example provided in this repository's README: https://codepen.io/travist/pen/xVyMjo

Maybe I am just not getting something, but it appears that the same behavior occur here. The <form-builder/> directive are only provided the form attribute, but still, I can see that there is a request being sent. In fact, there seem to be two requests being sent; one returns 401 and one returning 204:

image

Maybe you could check if the same happens for you?

travist commented 4 years ago

We will add this item to our planning to discuss and maybe prioritize resolution. Stay tuned.

travist commented 4 years ago

We believe this is just our "Existing Resources" that is querying to determine what resource fields should be added. If you want to remove this feature, it will require a change from the community to add an option to disable it. We need it for the Form.io platform.

vkvisli commented 4 years ago

Could you elaborate a little on what you mean by "Existing Resources" and "what resource fields should be added". What does the request do exactly?

Also, do you know if this is also the case with the form builder provided by the formio.js repository?

The reason I am asking is that I have a case where I need my application to run in an isolated environment, and would therefore like it not to do any external requests.

travist commented 4 years ago

When the form builder is embedded into your application (and also point to the Form.io project endpoint), it fetches the list of resources and their fields to add a new section called "Existing Resource Fields". You can see this in our commercial portal @ https://portal.form.io. This would just need to be turned off, but we do not have it as configurable. The good news is that this portion is open source, so please feel free to add that configuration for the open source implementations and we will accept it in the next builds.

vkvisli commented 4 years ago

Aha, I think I understand what you are saying now. Thank you for the explanation :)

The reason why I would like to prevent the request is that I don't actually have a Form.io project endpoint, and therefore the request is not necessary. In other words, I am only using the form builder as a local generator of form schemas.

Just as a final follow-up question on this: As you say, the form builder can point to a Form.io project endpoint, but is there any way of specifying that no project endpoint should be used? Or is this also not configurable?

randallknutson commented 4 years ago

You can see here the options to disable this functionality: https://github.com/formio/formio.js/blob/master/src/WebformBuilder.js#L311-L313