umbraco / Umbraco.Forms.Issues

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

Rich text in data consent #834

Open bjarnef opened 2 years ago

bjarnef commented 2 years ago

Currently the Data Consent field has a property "Accept Copy". I think the label of this maybe should be something different? Besides that it would be great it we could enter a rich text description.

For example in a newsletter signup you may want to specify a bit more detailed text and often part of the text would be linking to privacy policy, cookie policy or terms and conditions. Often there would be two links and could be inlined with the text.

Umbraco v10.0.1 Forms v10.0.5

AndyButland commented 2 years ago

Not quite answering this issue I release, but please note that we will have a rich text field type in 10.1. So you would be able to add this below the data consent field, to provide more context and links to the various privacy pages.

E.g. to create something like this:

Yes I give permission to process my data: [X]

By filling in the form you agree to our terms and conditions and privacy policy.

bjarnef commented 2 years ago

@AndyButland yes, that's definitely an improvement. Would the Data Content field include an richtext description or would we need to override Data Content field to archive this? https://our.umbraco.com/documentation/Add-ons/umbracoforms/developer/extending/Adding-a-Type#overriding-default-providers-in-umbraco-forms

Would a label like "Accept Conditions" or "Accept Consent" be better than "Accept Copy"?

AndyButland commented 2 years ago

No, I'm just suggesting you could add two fields to your form - one data consent field, and one rich text field underneath it.

bjarnef commented 2 years ago

Yeah, depending on the layout, it could be part of the Data Content field as another field would typical add some spacing below the field.

bjarnef commented 2 months ago

I had a though about this again and although we can add a separate rich text field, I think it would be easier to manage for content editors.

Furthermore when working with Forms templates and Custom Apply Workflows Behavior it would be easier to deal with a single field. https://docs.umbraco.com/umbraco-forms/developer/extending/customize-default-workflows

bjarnef commented 2 months ago

@AndyButland wasn't there is way to override a field type, to change configuration or add an extra richtext setting, while keeping the existing field type guid?

AndyButland commented 2 months ago

Can't say I've tried it, but seems like it

@AndyButland wasn't there is way to override a field type, to change configuration or add an extra richtext setting, while keeping the existing field type guid?

Can't say I've tried it, but seems like it should work. Make sure to remove the original field type in your composer as well as adding your new one though, otherwise you'll end up with a duplicate ID.

bjarnef commented 2 months ago

I think something like this may work: https://dev.to/andy_boot/umbraco-forms-add-additional-attributes-to-existing-field-types-4abg

Will try that out.. but I haven't seen it documented, but I think it is really useful.

bjarnef commented 2 months ago

It seems I get an

image

but I didn't seen duplicates although I didn't remove it:

image

this didn't seem to make a difference:

builder.WithCollectionBuilder<FieldCollectionBuilder>()
    .Exclude<DataConsent>() // core
    .Add<DataConsentField>(); // custom

The field type is extended with richtext setting though.

image

bjarnef commented 2 months ago

Nevermind, the error is because of the design view, where the class name doesn't match the DataConsent in Forms. So this works instead (or rename this class to match name).

public class DataConsentField : Umbraco.Forms.Core.Providers.FieldTypes.DataConsent
{
    /// <summary>
    /// Gets or sets the form field's body text.
    /// </summary>
    [Setting("Rich text", Description = "Enter your formatted text", SupportsPlaceholders = true, HtmlEncodeReplacedPlaceholderValues = true, View = "richtext", DisplayOrder = 10)]
    public virtual string Html { get; set; } = string.Empty;

    public override string GetDesignView() =>
        "~/App_Plugins/UmbracoForms/backoffice/Common/FieldTypes/DataConsent.html";
}