I need to add additional checkbox under Forms Settings tab.
How can I customize it?
Sitecore Stack Exchange is a question and answer site for developers and end users of the Sitecore CMS and multichannel marketing software. It only takes a minute to sign up.
Sign up to join this communitycore
database.You need to add it in core
database under /sitecore/client/Applications/FormsBuilder/Components/Layouts/FormSettingsPropertyGrid/PageSettings/SettingsForm
item:
It needs to be created based on FormCheckBox Parameters
template.
Exact path to that template:
/sitecore/client/Business Component Library/version 2/Layouts/Renderings/Forms/Form/Templates/FormCheckBox Parameters
or you can find it based on its ID also:
{AD75C314-F983-4C56-81D5-DC10D5CCF4EF}
You need to also enable this new control in ControlDefinitions field in parent item that is based on FormSection template. This needs to be done in order to render control under that form section:
There is already checkbox that you can use as starting point. Make your checkbox based on this item:
/sitecore/client/Applications/FormsBuilder/Components/Layouts/FormSettingsPropertyGrid/PageSettings/SettingsForm/Advanced/PerformanceTracking
You can do this but altering item template under this path /sitecore/templates/System/Forms/Form
and adding your custom shared checkbox field:
You will refer to this field name in next step shortly.
I would recommend creating your own Form template based on OOTB one located under the path - /sitecore/templates/System/Forms/Form and reference your newly created one but the reference is on so many places that it would be hard to do so.
For that you would need to create your own model class in your solution that will inherit Sitecore.ExperienceForms.Mvc.Models.FormViewModel class. It is located in Sitecore.ExperienceForms.Mvc.dll.
You need to add new property of type bool or string depending your requirements:
Reference your field created in step 2 here as Fields["Your_Custom_field_name"]
.
You also need to set your fields value in UpdateItem method:
and InitializeModel method to get current value of your custom parameter:
Instead of OOTB Sitecore.ExperienceForms.Mvc.Models.FormViewModel,Sitecore.ExperienceForms.Mvc class you need to change Model Type field in Form item in master
database in path /sitecore/system/Settings/Forms/Field Types/Form
to your custom class created in step 3.
You need to inherit from Sitecore.ExperienceForms.Mvc.FormRenderingContext class and add properties around your custom property.
Create patch config file to change this serviceType to your custom class at the end.
From:
<register serviceType="Sitecore.ExperienceForms.Mvc.IFormRenderingContext,
Sitecore.ExperienceForms.Mvc"
implementationType="Sitecore.ExperienceForms.Mvc.FormRenderingContext,
Sitecore.ExperienceForms.Mvc" lifetime="Transient" />
To:
<register serviceType="Sitecore.ExperienceForms.Mvc.IFormRenderingContext,
Sitecore.ExperienceForms.Mvc" implementationType="YouCustomImplementationClass,
YourAssembly" lifetime="Transient" />