Created
January 6, 2016 14:21
-
-
Save davidknipe/9e16834b86f4df46febb to your computer and use it in GitHub Desktop.
Constrained Textbox Element Form Element for EPiserver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.epi-forms-icon.epi-forms-constrainedtextboxelementblock__icon { | |
background-image: url(constrainedtextboxelementblock16x16.png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ import namespace="System.Web.Mvc" %> | |
<%@ import namespace="EPiServer.Web.Mvc.Html" %> | |
<%@ import namespace="EPiServer.Forms.Core.Models" %> | |
<%@ import namespace="EPiServer.Forms.Implementation.Elements" %> | |
<%@ control language="C#" inherits="ViewUserControl<$rootnamespace$.Business.Forms.ConstrainedTextbox.Block.ConstrainedTextboxElementBlock>" %> | |
<% var formElement = Model.FormElement; | |
var labelText = Model.Label; | |
var maxLength = Model.MaxLength; | |
%> | |
<div class="Form__Element FormTextbox" data-epiforms-element-name="<%: formElement.Code %>" > | |
<label for="<%: formElement.Guid %>" class="Form__Element__Caption"><%: labelText %></label> | |
<input name="<%: formElement.Code %>" id="<%: formElement.Guid %>" type="text" class="FormTextbox__Input" | |
placeholder="<%: Model.PlaceHolder %>" value="<%: Model.PredefinedValue %>" <%: Html.Raw(formElement.AttributesString) %> | |
maxlength="<%: maxLength %>" /> | |
<span data-epiforms-linked-name="<%: formElement.Code %>" class="Form__Element__ValidationError" style="display: none;">*</span> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel.DataAnnotations; | |
using EPiServer.DataAbstraction; | |
using EPiServer.DataAnnotations; | |
using EPiServer.Forms.Implementation.Elements; | |
namespace $rootnamespace$.Business.Forms.ConstrainedTextbox.Block | |
{ | |
[ContentType( | |
DisplayName = "Constrained Textbox", | |
GroupName = "Form Elements", | |
GUID = "5445D5A7-965F-45FF-BF49-5633B83F2ECF")] | |
public class ConstrainedTextboxElementBlock : TextboxElementBlock | |
{ | |
[Display( | |
GroupName = "Forms authoring", | |
Order = 1, | |
Name = "Max field length", | |
Description = "The maximum length of the input field"), | |
CultureSpecific] | |
public virtual int MaxLength { get; set; } | |
public override void SetDefaultValues(ContentType contentType) | |
{ | |
base.SetDefaultValues(contentType); | |
MaxLength = 10; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using EPiServer.Forms.EditView; | |
using EPiServer.Shell; | |
using $rootnamespace$.Business.Forms.ConstrainedTextbox.Block; | |
namespace $rootnamespace$.Business.Forms.ConstrainedTextbox.UIDescriptor | |
{ | |
[UIDescriptorRegistration] | |
public class ConstrainedTextboxElementBlockDescriptor : FormElementBlockDescriptor<ConstrainedTextboxElementBlock> | |
{ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<languages> | |
<language name="English" id="en"> | |
<contenttypes> | |
<constrainedtextboxelementblock> | |
<name>Constrained Textbox</name> | |
</constrainedtextboxelementblock> | |
</contenttypes> | |
</language> | |
</languages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<module> | |
<clientResources> | |
<add name="Forms" path="~/Business/Forms/ConstrainedTextbox/ClientResources/ConstrainedTextbox.css" resourceType="Style" /> | |
</clientResources> | |
</module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the icon that is associated