IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
You use form field templates to change the appearance of the form fields in Sitefinity CMS. Every form field has built-in templates that are packaged in the same assembly.
With MVC forms, you can override the default form field template by placing the physical file - either a CSS file, JavaScript, HTML, or other - in a specific location inside the SitefinityWebApp project structure. Sitefinity CMS searches for this location and, if it finds any of these files, uses them to replace the default form field template. The location depends on the built-in ASP.NET MVC view engines. By default, ASP.NET MVC comes with WebFormViewEngine and RazorViewEngine.
The following procedure describes how to change the built-in form field template depending on the view engine you are using.
By default, all MVC-oriented logic must reside in the Mvc folder in the SitefinityWebApp project. This folder is created automatically by Sitefinity CMS in your web application. Once you install the Feather project, the new MVC form fields appear in the Sitefinity CMS toolbox.
To modify the default template of the Textbox field that uses the RazorViewEngine:
In Visual Studio, open your SitefinityWebApp project and click Mvc » Views.
Create a new folder and name it TextField.
NOTE: The name of the folder must correspond to the name of the form field whose template you want to change. For example, if you need to change the template of the Submit button field, you must name the folder SubmitButton.
Open the context menu of the TextField folder and add a new file with name Write.Default.cshtml.
NOTE: The name of the file must be Write.Default because the TextField controller renders a view named Write.Default when a form field is to be filled. When a form field is displayed along with its value, for example when exploring the form submissions in the backend, these views begin with Read. In this specific case, the views begin with Read.Default. The extension .cshtml is valid for Razor view engine. For any other form field, the name of the newly created file must match the name of the template that you want to replace.
Enter a sample text, for example, enter Testing new template.
Build the solution and run it.
Create a new MVC form in Sitefinity CMS and place the TextField form field, which is already present in the toolbox section.
As a result, the Testing new template text is displayed.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important