Thursday, November 20, 2008

Custom fields with custom properties - important link

If you have developed a custom field type that has custom properties, and now want to create a feature that uses that custom field (to add a site column for example) and want to set the custom property, you may be puzzled how to set the custom property, since the schema of the elements file does not allow it.

I found that Péter Holpár has a solution - I tested, and it works. Basically, just add the custom property with a custom name space - for example, using my datevalidator field type from my teched presentation, you can define it as a site column thus (important bits are highlighted):

<?xml version="1.0" encoding="utf-8"?>
<!--
-->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"
xmlns:custom="http://www.sharepoint-tips.com/customfields">
 <Field ID="{BBC8063E-252E-4fc0-9DC6-CA162512BB33}"
        SourceID="http://schemas.microsoft.com/sharepoint/v3"
        Type="DateValidationFieldType"
        Name="MyTestValidationField"
        StaticName="MyTestValidationField"
        DisplayName="My Test Validation Field"
        Group="Custom"
        Hidden="FALSE"
        ReadOnly="FALSE"
        Required="FALSE"
        RowOrdinal="0"
        custom:StartDateFieldName="Start Date"
        custom:EndDateFieldName ="Due Date"
 >   
 </Field>
</Elements>


I hope it solves your questions as well.

No comments: