Search code examples
orchardcmsdynamic-forms

How to achieve Dynamic forms with `HTML <input> placeholder Attribute` in Orchard


I use Orchard CMS 1.10.1. How to use HTML <input> placeholder Attribute instead of labels in dynamic forms module?


Solution

  • Use the shape tracing feature from the designer tools module to find the right shapes to override, and what alternate templates to write. Most likely, you'll find that you need to override the Elements_TextField shape and replace:

    @if (element.ShowLabel) {
        <label for="@element.HtmlId">@Model.ProcessedLabel</label>
    }
    

    with:

    @if (element.ShowLabel) {
        tagBuilder.Attributes["placeholder"] = Model.ProcessedLabel;
    }