Here are our Kentico MVP, Matt's, tips on making life easier in the Kentico CMS desk by improving the forms application.
At Ridgeway, we’ve often thought that there are a few places where the CMS desk could make our lives a little easier. One of the little things - those one percent improvements - is in the forms application. Depending on what you’re doing with your form, you may want to simply display some text to the user once they’ve filled in the form to say “thank you”. The option we get for this is a simple text box, so everything you want to say goes in here.
Whilst I was running through some inductions for a couple of new developers recently, we walked through the forms application and this field grabbed my attention. What if I want to do something a little more than say “thanks” - how could this be improved?
Having previously read an article by Laura Frese about enriching the HTML support for notification email templates (Kentico Quick Tip: Full HTML Toolbar for Notification Templates), it got me thinking. Effectively, this was a catalyst to the idea that I could more than likely do something to the forms application to improve the editor experience.
What do you get out of the box?
The out-of-the-box feature of Kentico is to give you the option of one of four actions that can happen when you submit a form. The options you get are:
- Display text: displays some text that you provide.
- Redirect to URL: take me somewhere else - literally anywhere else - as long as it is a valid absolute or a relative URL.
- Clear form: simple clear the form fields, and do nothing else.
- Continue editing: carry on like nothing happened
Some options seem a bit odd at first glance, but they do all have their uses depending on the context in which you’re using the form. The two that are most interesting to me are ‘Display text’ and ‘Redirect to URL’. You notice how they’re both text boxes? This could be nicer - using a rich text editor and URL selector feels like it might be a bit friendlier, right?
Let’s take a look and see if we can easily enable a rich text editor for ‘Display text’.
Setting up the HTML editor for ‘Display text’
- Open ~/CMSModules/BizForms/Tools/BizForm_Edit_General.aspx
- Change txtDisplay from CMSTextBox to CMSHtmlEditor
- In code behind add method to init HtmlEditor that is called from the Page_Load
/// Initializes HTML editor's settings.
protected void InitHTMLEditor()
txtDisplay.AutoDetectLanguage = false;
txtDisplay.DefaultLanguage = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
txtDisplay.ToolbarSet = "BizForm";
txtDisplay.MediaDialogConfig.UseFullURL = true;
txtDisplay.LinkDialogConfig.UseFullURL = true;
txtDisplay.QuickInsertConfig.UseFullURL = true;
4. Modify references in code behind for txtDisplay.Text to txtDisplay.ResolvedValue
5. If you want, rename txtDisplay to something a little more reflective such as htmlEditor
Once that is done and you’ve given everything a quick build, you should be able to reload your forms application in CMS desk and be able to set some rich content as shown below:
This is a simple change, but as a content editor and forms administrator, it can give you greater control over what you display once your form is submitted in the cases where you don’t want a separate success page.
Disclaimer: As with many things, we’re changing some OOB features here - so you need to be careful when it’s hotfix time that you don’t simply lose these changes.