0

I need to add a custom field AuthorizedGroups for all my new Sitecore Forms, I created a new template based on /sitecore/templates/System/Forms/Form and added this new field to the template, but when I tried to create a new form this template is not available.

Is there a way to make it available to form designer?

[edit] I think I did not make it clear, I do not want to add a custom field to form designer and make it available to save data, I just need to add a property to form template, so I can tag formA's authorizeGroups = "GrpA" and formB's authorizeGroups = "GrpB,GrpC", It is one template level not on form instance level.

1

3 Answers 3

1

After you have configured the parameters for the field editors, you can now create the custom field type, for example, to enable you to add a video to your form.

To create the field type item:

  1. Go to /sitecore/system/Settings/Forms/Field Types/Basic folder and add a new item.
  2. Base the item on the /System/Forms/Field Type template, enter a name and click Insert. For example, Video.
  3. Edit the Settings section fields: View Path,Model Type, Property Editor.
  4. In the Appearance section, edit the following fields: Icon,BackgroundColor.
  5. In the Field template field, specify the field template you created previously. For example, sitecore/Templates/FormsDemo/Fields/Video. When you now create a new form, the custom video element is available in the Form elements pane.

Reference: https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-manager/walkthrough--creating-a-custom-form-element.html

Hope it helps!

0

The field is not visible because you have not followed all the steps to create a new field.

Here are the steps you can follow.

  1. Open core database and go to this location. (/sitecore/client/Applications/FormsBuilder/Components/Layouts/PropertyGridForm/PageSettings/Settings)

  2. You will see a list of form parameters. Choose anyone and make a copy and name if with your field name.

  3. Open master database and go to this location (/sitecore/templates/System/Forms/Fields). Here you will find the templates of all the controls. Select “Input” template and make a copy of it and name it with your new field name.

  4. Now go to this location to create your new control (/sitecore/system/Settings/Forms/Field Types/Basic) and fill the required fields.

If you have a different implementation then you need to write the code.

Follow my blog that can help you to create a new custom field with graphical representation.

https://sbhatiablogs.wordpress.com/2019/07/07/a-simple-file-upload-control-in-sitecore-9-forms/

Also there are some other example that you can follow.

Custom Drop Down:

https://blogs.perficient.com/2021/02/05/how-to-create-a-custom-dropdown-field-in-sitecore/

Custom Rich Text:

https://pushpaganan.home.blog/2020/02/06/adding-a-custom-rich-text-field-to-sitecore-forms/

Hope this helps.

0

To add a custom field to a Sitecore form, you can follow these general steps:

  1. Create the Custom Field Component: First, you need to create a custom field component that represents your custom field. This component should extend Sitecore.ExperienceForms.Mvc.Models.Fields.FieldViewModel.
  2. Define Model Properties: Within your custom field component, define properties that represent the data you want to collect with your custom field.
  3. Implement Editor and View: Implement the editor and view for your custom field. The editor allows content authors to configure the field in the Form Designer, while the view defines how the field is rendered on the front end.
  4. Add Field to Form Designer: Register your custom field with Sitecore Forms so that it appears in the Form Designer. This involves adding appropriate entries in configuration files.
  5. Handle Field Data: Implement logic to handle the data submitted through your custom field when the form is submitted.

enter image description here

In the above example, you would need to create a corresponding Razor view file named CustomField.cshtml which defines the HTML markup for rendering your custom field.

Ensure you also create a corresponding Editor view for configuring the field in the Form Designer.

After creating the custom field component and views, you'll need to register your custom field with Sitecore Forms. This typically involves adding configuration entries in files like Views.Forms.config and FormsBuilderModel.xml.

Lastly, you'll need to handle the data submitted through your custom field. You can do this by extending or overriding the default form submission behavior to process your custom field data appropriately.

Also there are some other example you can follow

https://pushpaganan.home.blog/2020/02/06/adding-a-custom-rich-text-field-to-sitecore-forms/

https://doc.sitecore.com/xp/en/developers/93/sitecore-experience-manager/walkthrough--creating-a-custom-rating-element.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.