stoneMaster
stoneMaster

Reputation: 207

Kentico 12 MVC - Customize BizForm response

I need to have a form defined within Kentico, which once submitted, will display a youtube video within the same page (no redirect). This would be similar to the "Display Text". Is there a way to override the existing response?

Upvotes: 1

Views: 238

Answers (1)

Dmitry Bastron
Dmitry Bastron

Reputation: 694

It doesn't look to be configurable inside Kentico out-of-the-box. And doesn't look too easy to implement, but I think it is still doable:

First, create your custom form widget and inherit it from KenticoFormWidgetController (you might need to override a few internal methods).

Then, implement your custom logic in FormSubmitInternal method - this is an example from the default widget:

if (!string.IsNullOrEmpty(bizFormInfo.FormDisplayText))
{
  string str = this.GetMacroResolver(bizFormInfo, bizFormItem, true).ResolveMacros(bizFormInfo.FormDisplayText, (MacroSettings) null);
  TagBuilder tagBuilder = new TagBuilder("div")
  {
    InnerHtml = str
  };
  tagBuilder.AddCssClass("formwidget-submit-text");
  return (ActionResult) this.Content(tagBuilder.ToString());
}

You can tie this logic to, for example, if there is a "video" word in Display text - do some of your logic and you can combine your own HTML markup there.

Upvotes: 3

Related Questions