Try our conversational search powered by Generative AI!

Unable to displayed the custom form field?

Vote:
 

Hi Guys,

       As per requirement i want to create my own form field,but when i drag and drop field its not displayed here is my code

namespace EpiserverSite5.Models.Blocks
{
  [ContentType(DisplayName = "CustomTextBoxElementBlock", GUID = "c5230b6e-7da0-4400-942c-0f33b6f801b6", Description = "")]
  public class CustomTextBoxElementBlock : TextboxElementBlock
  {
   [Display(
   Name = "Max length",
   Description = "The maximum number of characters.",
   Order = 2999)]
   public virtual int? MaxLength { get; set; }

  }
}

CustomTextBoxElementBlock.cshtml

@model EpiserverSite5.Models.Blocks.CustomTextBoxElementBlock
@using System.Web.Mvc
@using EPiServer.Forms.Helpers.Internal
@using EPiServer.Forms.Implementation.Elements
@using EPiServer.Forms.EditView.Internal
@using EPiServer.ServiceLocation

@{
    var errorMessage = Model.GetErrorMessage();
    var errorStyle = string.IsNullOrEmpty(errorMessage) ? " display:none" : string.Empty;
    var validationService = ServiceLocator.Current.GetInstance();
  }
     


       data-f-element-name="@Model.FormElement.ElementName" data_f_type="textbox">
     
     
      id="@Model.FormElement.Guid"
     type="text"
      class="FormTextbox FormTextbox__Input @Model.FormElement"
     placeholder="@Model.PlaceHolder"
    value="@Model.GetDefaultValue()"
    @Html.Raw(Model.AttributesString) />
     
     class="Form__Element__ValidationError"
    style="@errorStyle">@errorMessage

    @Model.RenderDataList()

When i drag form fied into form container,i get this  error

Error:

The  'CustomTextBoxElementBlock' can not  be displayed

Can any one help me out of this.

Thanks,

Kartheek

#187064
Jan 11, 2018 6:28
Vote:
 

I usually get this error when there is an error in the view. Are you seeing any errors in the event logs? Where did you place your view for the Form? 

Can you have a very simple view with just a simple HTML input field on it? 

#187202
Jan 15, 2018 23:48
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.