gpt4 book ai didi

sitecore - 扩展 Sitecore WFFM 字段类型

转载 作者:行者123 更新时间:2023-12-04 20:36:50 26 4
gpt4 key购买 nike

我想向 WFFM 表单字段类型添加其他属性。

内置字段类型在表单设计器的左侧具有属性 enter image description here

我想在这个区域添加我自己的部分和属性。
这可以在不覆盖现有字段类型或修改核心代码的情况下轻松完成吗?

我真的不想重新创建例如单行文本字段只是为了添加我自己的属性字段。

最佳答案

不幸的是,实现它的唯一方法是创建自定义 Field Type在实现现有字段的代码中,例如Single Line Text .没有其他配置可以更改,您必须通过代码添加属性,能够采用和扩展“核心”代码是 Sitecore 众所周知的。

但是添加这些属性真的很简单,如果你只是实现现有的,就不必重新开发每个字段。然后只需从 Type 中选择您的自定义单行文本下拉列表并查看您的新属性..

实现现有的 Fields会给你一切Single Line Text开箱即用的属性,现在您需要在新的 class 中定义属性.属性本身是 public properties用视觉属性装饰你的类(class)。

例如,我想要一个属性来保存 FileUpload 的文件大小限制。字段,可以通过添加公共(public) string 来完成属性(property);

public class CustomSingleLineText : SingleLineText
{
private int _fileSizeLimit;

// Make it editable
[VisualFieldType(typeof(EditField))]
// The text display next to the attribute
[VisualProperty("Max file size limit (MB) :", 5)]
// The section the attribute appers in
[VisualCategory("Appearance")]
public string FileSizeLimit
{
get
{
return this._fileSizeLimit.ToString();
}
set
{
int result;
if (!int.TryParse(value, out result))
result = 5;
this._fileSizeLimit = result;
}
}

然后,您可以通过从 Parameters 获取内容编辑器在提交或验证者中输入的属性值来访问它。的 FieldItem - 字段项[“参数”]

有关完整示例源,请参见这篇文章;

http://jonathanrobbins.co.uk/2015/10/06/sitecore-marketplace-module-secure-file-upload/

关于sitecore - 扩展 Sitecore WFFM 字段类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33597747/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com