Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pedro Tavares 10 posts 90 karma points c-trib
    Jan 28, 2015 @ 18:50
    Pedro Tavares
    0

    Umbraco Forms - Custom Fields

    Hi guys,

    I'm trying to build a custom DropDownList with custom values using a third party service.

    I'm stuck with two options.

    #1 - New FieldType

    public class CustomField: Umbraco.Forms.Core.FieldType
    {
        public CustomField()
        {
            this.DataType = FieldDataType.[String|LongString|Integer|DateTime|Bit];
        }
    }
    

    Issues

    • How can I specify that my CustomField will be a DropDownList?

    #2 - New FieldPreValueSourceType

    public override List<PreValue> GetPreValues(Field field, Form form)
    {
        List<PreValue> result = new List<PreValue>();
        ...
        return result;
    }
    

    Issues

    • How can I set the default value? Not static, but dynamic.

    Any tip on this?

    Cheers,

    /Pedro

  • Pedro Tavares 10 posts 90 karma points c-trib
    Jan 29, 2015 @ 11:21
    Pedro Tavares
    100

    I figured out that adding this line

    this.SupportsPrevalues = true;
    

    into a FieldType constructor enables a DropDownList.

    Now I can set the selected value inside the view.

    /Pedro

Please Sign in or register to post replies

Write your reply to:

Draft