Wenn Sie MVC-Version von WFFM verwenden, müssen Sie folgende hinzufügen, wie in genehmigt Antwort erklärt
1- Erstellen Sie eine Klasse
public interface IPlaceholderField
{
string PlaceHolder { get; set; }
}
[ValidationProperty("Text")]
public class SingleLineText : Sitecore.Form.Web.UI.Controls.SingleLineText, IPlaceholderField
{
[VisualCategory("Custom Properties")]
[VisualProperty("Placeholder", 2)]
[DefaultValue("")]
public string PlaceHolder { get; set; }
protected override void OnInit(EventArgs e)
{
// Set placeholder text, if present
if (!string.IsNullOrEmpty(PlaceHolder))
{
textbox.Attributes["placeholder"] = PlaceHolder;
}
base.OnInit(e);
}
}
public class ExtendedSingleLineTextField : Sitecore.Forms.Mvc.ViewModels.Fields.SingleLineTextField, IPlaceholderField
{
[VisualCategory("Custom Properties")]
[VisualProperty("Placeholder", 2)]
[DefaultValue("")]
public string PlaceHolder { get; set; }
}
2- Kopieren einzeiligem Text von /Sitecore/System/Module/Web Forms für Marketer/Einstellungen/Feld Typen/Einfache Typen/Einzeiliger Text zu /SiteCore/System/Module/Web Forms für Marketer/Einstellungen/Feldtypen/Benutzer Set Baugruppe, Klasse und MVC Typ
3-Erstellen Sie eine neue chtml Datei unter \ Views \ Formular \ EditorTemplates ane Name es ExtendedSingleLineTextField.cshtml sollte es denselben Namen mit dem Klassennamen (ExtendedSingleLineTextField)
@using Sitecore.Forms.Mvc.Html
@using LendLease.Web.HtmlHelpers
@model LendLease.Extension.Sc.WFFM.ExtendedSingleLineTextField
@using (Html.BeginField())
{
@*@Html.TextBoxFor(m => m.Value, new { placeholder = Model.PlaceHolder })*@
@Html.ExtendedBootstrapEditor("value",Model.PlaceHolder,"",new []{""})
}
Add sein ein HTML-Helfer, so können Sie Platzhalter injizieren Ich nannte es BootstrapEditorHtmlHelperExtension.cs
public static class BootstrapEditorHtmlHelperExtension
{
public static MvcHtmlString ExtendedBootstrapEditor(this HtmlHelper helper, string expression, string placeholderText, string inlineStyle, string[] classes)
{
var str = string.Empty;
var viewModel = helper.ViewData.Model as IViewModel;
if (viewModel != null)
{
var styleSettings = viewModel as IStyleSettings;
if (styleSettings != null)
{
str = styleSettings.CssClass;
}
if (string.IsNullOrEmpty(placeholderText))
{
placeholderText = viewModel.Title;
}
}
return helper.Editor(expression, new
{
htmlAttributes = new
{
@class = (string.Join(" ", classes) + " form-control" + (string.IsNullOrEmpty(str) ? string.Empty : " " + str) + (helper.ViewData.Model is SingleLineTextField ? " dangerousSymbolsCheck" : string.Empty)),
placeholder = placeholderText,
style = (inlineStyle ?? string.Empty)
}
});
}
}
Dank @Derek .... Tht war sehr hilfreich :) – Bevin
Hallo Leute, gilt dies noch für WFFM 8.1? – Jawad