Here's the code of FormItem.setEditorType() from the latest SVN:
So only the type of the editor is preserved even though the method requires the object literal (meaning you have to create an object and throw it away...)
But that's no big deal. The biggest problem with this is the settings on the editor are thrown away too. There's no way to use a customized editor for the formItem.
For example, I'm using TextItem to store the date literal that's required by ASP.NET JSON service (format as: /Date(123456)/), so I set the TextItem's editor type to DateItem, and provide a customized InputFormat to format the picked date to the string literal required by my web service. However, with the default DateItem, I'm not allowed to set it to empty (always default to today), and searching on the forum I found I need to set useTextField property to true on DateItem, but I can't because the default is always going to be used...
Maybe provide an API that allows user to set a specific editor instance on the field?
Code:
public void setEditorType(FormItem editorType) { setAttribute("editorType", editorType.getType()); }
But that's no big deal. The biggest problem with this is the settings on the editor are thrown away too. There's no way to use a customized editor for the formItem.
For example, I'm using TextItem to store the date literal that's required by ASP.NET JSON service (format as: /Date(123456)/), so I set the TextItem's editor type to DateItem, and provide a customized InputFormat to format the picked date to the string literal required by my web service. However, with the default DateItem, I'm not allowed to set it to empty (always default to today), and searching on the forum I found I need to set useTextField property to true on DateItem, but I can't because the default is always going to be used...
Maybe provide an API that allows user to set a specific editor instance on the field?