A while ago I posted about Custom Field Type, wherein I mentioned a problem I was having getting my custom properties to stick when saving a field.
I posted a question to the MSDN Forum about this and received a pretty promising response, which goes half way but is still not the complete answer.
The response from Anton Myslevich (thanks Anton!) has details of defining the properties in the propertyschema element, making them hidden, overriding the Update method to set the custom properties like this...
public override void Update()
{
this.SetCustomProperty("MyProp", this.MyProp);
base.Update();
}
...and then using an Init method that is called from the constructors to set the values when the custom field is edited...
private void Init()
{
this.MyProp = this.GetCustomProperty("MyProp") + "";
}
This works great for the edit/save/re-edit process, but it still does not save the properties when a new instance of the field is created. For my current purposes, this is ok, because I cam deploying the custom field type as part of a list definition and so my instance is created already and because editing now works ok, I'm saved - for now.
I'm still pretty keen to know how to get the entire process working properly, and I'm wondering if I can perhaps modify the field definition to show the propertyschema fields initially, and then hide them and show the custom field editor control when the field is edited.
If anyone has any further thought, I'd be more than happy to hear them...