umbraco / Umbraco.Forms.Issues

Public issue tracker for Umbraco Forms
29 stars 0 forks source link

Scaffold form fields #1169

Closed bjarnef closed 1 month ago

bjarnef commented 4 months ago

Sometimes I think it could be nice to scaffold forms fields that should always be adding, e.g. recaptcha or data constent. I am nor sure if is it possible to customize the templates.

Maybe Forms could use something similar the Content Templates / Blueprints?

Furthermore it would be great if some fields could be "locked", so recaptcha or data constent can't be removed (or maybe only by admins?) - and that these only was allowed to add once per form.

AndyButland commented 4 months ago

You have this option for amending what fields are added to all forms.

You can also create your own templates - if you create a form to your liking, export it and save the JSON file in App_Plugins\UmbracoForms\Data\Templates, that should get picked up in the "Create form" dialog.

bjarnef commented 1 month ago

@AndyButland regarding templates for "Create form" I couldn't find anything about this in the documentation, but I couldn't copy a have a look at default JSON files in static assets NuGet package.

Is is possible to specific another location that App_Plugins\UmbracoForms\Data\Templates e.g. App_Plugins\MyFormExtensions\Data\Templates ?

For each field there is an fieldTypeId and id .. I guess the id could just be an unique random guid? The easiest it probably to review request of an existing form to find fieldTypeId etc.

I think it could be nice if there from backoffice was a "Save as template" for existing form.

Furthermore I wonder it if would be better to move templates to database? Which would be more consistent with content templates / blueprints in core and possible easier to modify later.

I added a new template, but it seems the existing doesn't show up then. image

I added another one for contactform.json copied from NuGet package, but it doesn't seem to show up.

image

I tried clearing browser cache, recycling application, anything I am missing?

AndyButland commented 1 month ago

Is is possible to specific another location that App_Plugins\UmbracoForms\Data\Templates e.g. App_Plugins\MyFormExtensions\Data\Templates ?

No, they need to be in App_Plugins\UmbracoForms\Data\Templates

For each field there is an fieldTypeId and id .. I guess the id could just be an unique random guid?

Yes, that's right. Though when a form is created from a template, new IDs are generated so we don't have the same ones used across more than one form.

The easiest it probably to review request of an existing form to find fieldTypeId etc.

You can do that, or you can export a form.

I think it could be nice if there from backoffice was a "Save as template" for existing form.

That's basically what the export form does. As I described in an earlier comment, _"you can also create your own templates - if you create a form to your liking, export it and save the JSON file in App_Plugins\UmbracoForms\Data\Templates, that should get picked up in the "Create form" dialog."_

I added a new template, but it seems the existing doesn't show up then.

This seems OK for me, but I'll pick up in the other issue you have raised

I'll close this one having answered the questions.