Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to create custom FieldTypes, SettingTypes and RenderTypes without altering the UmbracoForms folder #13

Closed
sussexrick opened this issue Sep 6, 2018 · 8 comments

Comments

@sussexrick
Copy link

Observed using Umbraco 7.6.13 and Forms 6.0.8:

When creating a custom field type, the view for previewing the field in the back office has to go under ~\App_Plugins\UmbracoForms\BackOffice\Common\FieldTypes.

When creating a custom setting type, the view for the setting editor has to go under ~\App_Plugins\UmbracoForms\BackOffice\Common\SettingTypes.

When customising the display of a field in the entries viewer, the view has to go under ~\App_Plugins\UmbracoForms\BackOffice\Common\RenderTypes.

It would be better if these customisations could go under our own folder under App_Plugins or somewhere under ~\Views\Partials\Forms so that we don't have to modify the content of the Umbraco Forms plugin itself.

@umbrabot
Copy link

Hiya @sussexrick,

Just wanted to let you know that we noticed that this issue got a bit stale and might not be relevant any more.

We will close this issue for now but we're happy to open it up again if you think it's still relevant (for example: it's a feature request that's not yet implemented, or it's a bug that's not yet been fixed).

To open it this issue up again, you can write @umbrabot still relevant in a new comment as the first line. It would be super helpful for us if on the next line you could let us know why you think it's still relevant.

For example:

@umbrabot still relevant
This bug can still be reproduced in version 8.9.0

This will reopen the issue in the next few hours.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@umbrabot umbrabot added the status/stale Marked as stale due to inactivity label Dec 17, 2020
@sussexrick
Copy link
Author

@umbrabot still relevant

The documentation still only describes putting views for custom field types inside the App_Plugins/UmbracoForms folder.

The location of custom views for setting types is not mentioned and I cannot see any mention of custom render types.

@umbrabot umbrabot reopened this Jan 11, 2021
@benjiew
Copy link

benjiew commented Nov 11, 2021

I've noticed a similar issue to this when creating custom field types... during a project rebuild, any custom back office files are deleted due to the "ClearUmbracoFormsAssets" target in Umbraco.Forms.targets cleaning the entire App_Plugins\UmbracoForms directory.

@AndyButland
Copy link

Just had a look at this - it is the case that a clean operation will remove the App_Plugins/UmbracoForms folder, and that's as per design for V9 - the idea being that a clean will remove files installed from NuGet packages following a dotnet build.

It looks like field type settings have always supported a full path to the view though, so you can specify a custom field type like this:

        [Setting("MyField", View = "~/App_Plugins/UmbracoFormsExtensions/backoffice/Common/SettingTypes/mytextfield.html", DisplayOrder = 10)]
        public string MyField { get; set; }

And so by storing any custom client-side files in a different folder within App_Plugins, they won't be removed following a clean.

Do please let me know if you think we've overlooked something here though.

@sussexrick
Copy link
Author

@AndyButland Can you confirm that specifying the full path works for all three types? And can we get documentation updated with the recommended approach as it still says custom views go under App_Plugins/UmbracoForms?

@AndyButland
Copy link

Hi @sussexrick - I've reviewed this morning and can confirm the following:

Settings types

These are the ones used to define the editor for a field type setting, e.g. the "Placeholder" value for the built-in "Short answer" field type. For these you can set a full path to a view file, so these can live outside of App_Plugins/UmbracoForms.

E.g.

[Setting("Placeholder", Description = "Enter a HTML5 placeholder value.", View = "~/App_Plugins/UmbracoFormsExtensions/backoffice/Common/SettingTypes/greentextfield.html", DisplayOrder = 20)]
public string Placeholder { get; set; }

image

Field types

These are used when in the main area of the form designer to show a preview of how the field will look on the form. This is defined by overriding the GetDesignView() method on a custom field type, and a full path can be used here, e.g.:

public override string GetDesignView() => "~/App_Plugins/UmbracoFormsExtensions/backoffice/Common/FieldTypes/greentextfield.html";

image

Render types

These are used when viewing the entries for a form, to render out the field value. They are set by overriding the RenderView property on a custom field type.

Here though a full path isn't supported - Forms is expecting just a name of a file here, and it's looking for it in App_Plugins/UmbracoForms, so we'll need to fix that up, at least for V9, but probably back-ported to V8 too.

I've tested a small update locally which will allow the following to work (and will PR and get this ready for the next releases):

public override string RenderView => "~/App_Plugins/UmbracoFormsExtensions/backoffice/Common/RenderTypes/greentextfield.html";

image

Will also make sure the documentation is updated to reflect this.

@benjiew
Copy link

benjiew commented Nov 16, 2021

Also on a related note (although I appreciate may be a separate issue), custom form templates located in the Data/Templates directory are also cleared after a clean.

@AndyButland
Copy link

Yes, noted @benjiew - am going to look also at modifying the "dotnet clean" target so we remove only the one we ship with.

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

No branches or pull requests

5 participants