Try our conversational search powered by Generative AI!

Input html helpers name generation after migration


Hi, after migrating to CMS 12 we've noticed that the names of input elements have changed.

Where a name on a input element used to be "FirstName" we are now seeing it as "CurrentPage.AboveTheFoldContentArea.Content.Content.Content.Content.RightContent.FirstName"

Could anybody provide any insight please?

Code example

Where previously

public class TestViewModel
    public string FirstName { get; set; }
    public string LastName { get; set; }

with the following view

@Html.TextboxFor(_ => _.FirstName)

would generate the following HTML

<input type="text" name="text" name="FirstName" />

after the upgrade we are now seeing the outputted html :

<input type="text" name="CurrentPage.AboveTheFoldContentArea.Content.Content.Content.Content.RightContent.FirstName">

The new controller which creates the View model

public class RequestCallbackBlockController : BlockComponent<TestBlock>
    protected override IViewComponentResult InvokeComponent(TestBlock currentContent)
        var viewModel = new TestViewModel();
        return View("TestBlock.cshtml", viewModel);

We are seeing the same behaviour using tag-helpers too.

Edited, Mar 08, 2023 1:26

To update this further, a workaround we have found is to set HtmlFieldPrefix  to null in ViewData in every place where we use a form field.

ViewData.TemplateInfo.HtmlFieldPrefix = null;

This would seem an odd behaviour to have to override each time a form is used?

Mar 09, 2023 3:12

This is something with MVC helper and nothing to do with Optimizely. But you can  add below in layout page or other global partial view?

ViewData.TemplateInfo.HtmlFieldPrefix = null;

So, you don't need to add it to all pages.

Mar 10, 2023 9:30
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.