Copied to clipboard

Flag this post as spam?

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


  • Bobby Perez 13 posts 33 karma points
    Jan 30, 2012 @ 02:53
    Bobby Perez
    0

    Custom Contour Fields

    Hi Guys,

    I'm working on extending contour forms for iPad. My goal for the moment is to render an input text field that will render as "<input type="email" ..... " so that this will render as a field to enter an email address.

    Here's my first try of extending contour ....

    namespace Foodstuffs.Umbraco.NewWorldKiosk.contourControls
    {
        public class TextfieldEmail : FieldType
        {
            public System.Web.UI.WebControls.TextBox tb; 
            public List<Object> _value;
    
            public TextfieldEmail()
            {
                this.Id = new Guid("74d7dfda-dac5-4e29-8eb6-9843a98f8794");
                this.Name = "iPad Email Field"; 
                this.Description = "Renders a html5 email input";
    
                this.Icon = "textfield.png"; 
                this.DataType = FieldDataType.String;
                tb = new TextBox(); _value = new List<object>();
            }
    
            public override WebControl Editor
            {
                get {
                    tb.TextMode = System.Web.UI.WebControls.TextBoxMode.SingleLine;
                    tb.CssClass = "email";
                    return tb;     
                }
    
                set { base.Editor = value; }
            }
    
            public override List<Object> Values
            {
                get{ if (tb.Text != "") { _value.Clear(); _value.Add(tb.Text); } return _value; }
                set{ _value = value; }
            }
    
            public override string RenderPreview() { return "<input type=\"email\" class=\"text\" />"; }
    
            public override string RenderPreviewWithPrevalues(List<object> prevalues) { return RenderPreview(); }
    
            public override bool SupportsRegex { get { return true; } }
    
        }
    }

    I tried changing the value for RenderPreview() from 

    "<input type=\"text\" class=\"text\" />"
    

    to 

    "<input type=\"email\" class=\"text\" />"

    but I ended up having another <input type="text" .....

    can someone enlighten me on this one, please?

    Thanks

     

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Jan 30, 2012 @ 10:57
    Tim
    1

    Hi Bobby,

    I think the renderpreview method is just used by the Contour UI to render the field in the forms editor UI. If you look at the source there, is it showing up as type="email"?

    I believe that the part you need to change for what gets rendered in the actual for is the part for "public override WebControl Editor".

    You need to update that part to return an ermail field. You may need to use a HtmlInputText control instead of a textbox, as that should alow you to set the type to "email".

    Hope that helps!

    :)

Please Sign in or register to post replies

Write your reply to:

Draft