Copied to clipboard

Flag this post as spam?

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


  • nk 1 post 71 karma points
    Aug 21, 2017 @ 15:55
    nk
    0

    custom field default value

    Hi There,
    if i want to set default view to custom field , how do you do this.

    for example for below code , how to enter default value

    thanks

    public class Textfield : FieldType

    {
    
    
    
    
    
        public Textfield() {
    
            //Provider
    
            this.Id =newGuid("3F92E01B-29E2-4a30-BF33-9DF5580ED52C");
    
            this.Name = "Textfield";
    
            this.Description ="Renders a html input fieldKey";
    
    
    
            //FieldType
    
            this.Icon = "icon-autofill";
    
            this.DataType = FieldDataType.String;
    
    
    
            this.Category = "Simple";
    
            this.SortOrder = 10;
    
        }
    
  • Craig 4 posts 74 karma points
    Jan 10, 2023 @ 10:55
    Craig
    0

    To get this to work for me i added another "using" to the top of the .cs file.

    using Umbraco.Forms.Core.Attributes;
    

    Then inside your public class Testfield : FieldType i added

    [Setting("DefaultValue", Description = "Enter a default value", View = "TextField")]
        public string DefaultValue { get; set; }
    

    This should then make an option in the settings when configuring the field to add a Default Value.

Please Sign in or register to post replies

Write your reply to:

Draft