OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.35k stars 2.37k forks source link

Liquid and Form controls #7245

Open arkadiuszwojcik opened 3 years ago

arkadiuszwojcik commented 3 years ago

I have question regarding previous issue I reported: #4426 Looks like it was solved by: #5099

Today I made test by replacing my custom tag helper:

{% helper "form-input", id:'Name', name:'Name', placeholder:'Your name', class:'form-control' %}

with:

{% helper "input", for: "Name", placeholder:'Your name', class: "form-control" %}

And the result I get is:

<input placeholder="Your name" class="form-control" type="text" id="ContentItem_Name" name="ContentItem.Name" value="">

instead of my previous:

<input id="Name" placeholder="Your name" class="form-control" name="Name" value="">

Notice: ContentItem_ and ContentItem. prefix. Is it exected behaviour? I would not expect any prefix before Name

/cc @ns8482e @jtkech

ns8482e commented 3 years ago

@arkadiuszwojcik I guess yes, default Prefix is name of the type of Model and ContentDisplayDriver has ContentItem as Model.

ns8482e commented 3 years ago

@arkadiuszwojcik I believe this only happens when you use Liquid widget in FlowPart , layers and not when used in liquid Templates.

arkadiuszwojcik commented 3 years ago

@ns8482e I had this issue using this code directly in my LiquidPageContent Definition (simple LiquidPartwrapper in my project) so no FlowPart, Layers were involved. And my LiquidPage is rendered directly in main Layout.

arkadiuszwojcik commented 3 years ago

@ns8482e This is what I found so far. Prefix is appended by inter MVC method: GetFullHtmlFieldNameexecuting while generating fields. Prefix is obtained this way: var htmlFieldPrefix = viewContext.ViewData.TemplateInfo.HtmlFieldPrefix; In our case it is ContentItem that is why finally we see: ContentItem_FieldName

arkadiuszwojcik commented 3 years ago

I don't understand one thing. Why when I use Form with some Workflow (as backend) I don't get any ContentItem prefixes for model fields. But when I use very same form against custom Controller then this prefix is appended? It is very incosistient behaviour.