I have created a custom field tyep which is the same as the standard 'textfield' just with a different name. I have done this to target specific text fields with css.
The form fails to save when the custom FieldType is implented.
public class MonetaryTextField : FieldType { public List<object> Value; public MonetaryTextField() { Id = new Guid("57ADD3AB-C3CD-464D-BCC2-3D1C05D3BF65"); Name = "Monetary Text Field"; Description = "Adds monetary formating to the form field"; Icon = "textfield.png"; DataType = FieldDataType.String; Value = new List<object>(); } public override string RenderPreview() { return "<input type=\"text\" />"; } public override string RenderPreviewWithPrevalues(List<object> prevalues) { return RenderPreview(); } public override WebControl Editor { get { System.Web.UI.WebControls.TextBox tb = new System.Web.UI.WebControls.TextBox(); tb.TextMode = System.Web.UI.WebControls.TextBoxMode.SingleLine; tb.CssClass = "monetary-field"; return tb; } set { base.Editor = value; } } }
On submit I am getting:
Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.]
Custom FieldType not saving
I have created a custom field tyep which is the same as the standard 'textfield' just with a different name. I have done this to target specific text fields with css.
The form fails to save when the custom FieldType is implented.
On submit I am getting:
Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Forms.Data.Storage.RecordFieldValueStorage.InsertRecordFieldValues(RecordField rf) +677
Umbraco.Forms.Data.Storage.RecordFieldStorage.InsertRecordField(RecordField recordfield) +1196
Umbraco.Forms.Data.Storage.RecordStorage.InsertRecord(Record record, Form form) +1865
Umbraco.Forms.Core.Services.RecordService.() +205
Umbraco.Forms.Core.Services.RecordService.Submit() +39
Umbraco.Forms.Core.Services.RecordService.NextPage() +169
Umbraco.Forms.UI.Usercontrols.RenderForm.nextPage(Object sender, EventArgs e) +241
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +153
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3706
What am I doing wrong? Any help would be appreciated.
This is my fault for not reading the Developer Docs correctly the two correct method overrides are:
is working on a reply...