Input.ShowHeader("Contact Us");
Input.ShowTextBox("Page Title", "page_title");
Input.ShowWysiwyg("Address", "address", ServicesInput.FullWYSIWYG());
Input.ShowTextBox("Customer Service Phone", "customer_service_phone");
Input.ShowTextBox("Email", "email");
<h1><%= asset["page_title"] %></h1>
<p><%= asset["address"] %></p>
<p><%= asset["customer_service_phone"] %></p>
<p><a href='mailto:<%= asset["email"] %>'><%= asset["email"] %></a></p>
using System.Text.RegularExpressions;
using CrownPeak.CMSAPI;
/* Some Namespaces are not allowed. */
namespace Developer_Training.Project.Library
{
public static class PostInputHelper
{
public static bool RequiredField(Asset asset, PostInputContext context, string field)
{
bool isValid = true;
if (!context.InputForm.HasField(field))
{
context.ValidationErrorFields.Add(field, "This is a required field");
isValid = false;
}
else if (!asset.Label.Equals(context.InputForm[field]))
{
asset.Rename(context.InputForm[field]);
}
return isValid;
}
public static bool ValidEmail(Asset asset, PostInputContext context, string field)
{
bool isValid = true;
if (!Regex.IsMatch(context.InputForm[field], @"^[^@\s]+@[^@\s]+\.[^@\s]+$"))
{
context.ValidationErrorFields.Add(field, "Please enter a valid email address");
isValid = false;
}
else if (!asset.Label.Equals(context.InputForm[field]))
{
asset.Rename(context.InputForm[field]);
}
return isValid;
}
}
}
PostInputHelper.RequiredField(asset, context, "page_title");
PostInputHelper.ValidEmail(asset, context, "email");
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.