Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

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

Open
vkvisli opened this issue Jun 18, 2020 · 8 comments
Open
Labels

Comments

@vkvisli
Copy link

vkvisli commented Jun 18, 2020

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 :)

@vkvisli vkvisli added the bug label Jun 18, 2020
@vkvisli vkvisli changed the title How to prevent request to form.io API (api.form.io/form)? [QUESTION] How to prevent request to form.io API (api.form.io/form)? Jun 18, 2020
@travist
Copy link
Member

travist commented Jun 18, 2020

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
Copy link
Author

vkvisli commented Jun 18, 2020

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
Copy link
Member

travist commented Jun 19, 2020

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

@travist
Copy link
Member

travist commented Jun 22, 2020

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
Copy link
Author

vkvisli commented Jun 26, 2020

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
Copy link
Member

travist commented Jun 26, 2020

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
Copy link
Author

vkvisli commented Jun 29, 2020

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
Copy link
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants