4

This is the code behind.

namespace web.insurance.Models
{
    public class SingleLineTextWithPlaceholderField : Sitecore.Forms.Mvc.ViewModels.Fields.SingleLineTextField
    {
        [Default Value("")]
        public string  PlaceholderText { get; set; }
        public SingleLineTextWithPlaceholderField(Item item) : base()
        {

        }
    }
}

This is the screenshot of Form designer. I want to have a custom field. I added above class and a cshtml file as a view. But the property **PLaceholdertext** is not showing in the Form Designer as mentioned in the image.

4

You need to tell the form editor that you want that field to be editable by an attribute, e.g. the line

[VisualFieldType(typeof(EditField))]

before

public string PlaceholderText { get; set; }

should do the trick.

In case Visual studio can't resolve the namespace try adding

using Sitecore.Form.Core.Attributes;

See e.g. https://github.com/islaytitans/FileUploadValidator/blob/master/JonathanRobbins.FileUploadValidator/Webforms/Controls/SecureFileUpload.cs for an example of fields with different editable properties.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.