Beispiel #1
0
        public string RenderLabel(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter   = new HtmlTextWriter(stringWriter);

            var bootStrapBuilderParameters = (BuilderParameters)formBuilderParameters;
            // if there is a Name specified in the DisplayAttribute use it , other wise use the property name
            var displayName = formElement.ControlSpecs.ControlName.SpacePascal();

            if (!String.IsNullOrEmpty(formElement.ControlSpecs.Name))
            {
                displayName = formElement.ControlSpecs.Name;
            }

            // Label
            if (bootStrapBuilderParameters.FormType == BootstrapFormType.Horizontal)
            {
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-3 control-label");
            }
            else
            {
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "control-label");
            }

            textWriter.AddAttribute(HtmlTextWriterAttribute.For, formElement.ControlSpecs.ControlName);
            textWriter.RenderBeginTag(HtmlTextWriterTag.Label);
            textWriter.Write(displayName);
            textWriter.RenderEndTag(); // label
            return(sb.ToString());
        }
        public void RenderLabel(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var bootStrapBuilderParameters = (BootStrapBuilderParameters)formBuilderParameters;
            // if there is a Name specified in the DisplayAttribute use it , other wise use the property name 
            var displayName = formElement.ControlSpecs.ControlName.SpacePascal();

            if (!String.IsNullOrEmpty(formElement.ControlSpecs.Name))
            {
                displayName = formElement.ControlSpecs.Name;
            }

            // Label
            if (bootStrapBuilderParameters.FormType == BootstrapFormType.Horizontal)
            {
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-3 control-label");
            }
            else
            {
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "control-label");
            }
            textWriter.AddAttribute(HtmlTextWriterAttribute.For, formElement.ControlSpecs.ControlName);
            textWriter.RenderBeginTag(HtmlTextWriterTag.Label);
            textWriter.Write(displayName);
            textWriter.RenderEndTag(); // label
        }
Beispiel #3
0
        public string BuildForm(List <FormElement> formElements, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();

            sb.Append(RenderHiddenFields(formElements));

            var groupsofElements = formElements.OrderBy(x => x.ControlSpecs.GroupName).GroupBy(x => x.ControlSpecs.GroupName);
            var useLegend        = (formElements.Select(x => x.ControlSpecs.GroupName).Distinct().Count() > 1);

            foreach (var groupedElements in groupsofElements)
            {
                var groupName = (!String.IsNullOrEmpty(groupedElements.Key)) ? groupedElements.Key : "General";

                sb.Append(this.layoutBuilder.BeginFieldCollection(groupName, useLegend, formBuilderParameters));
                {
                    var elementsToRender = groupedElements.Where(x => x.ControlSpecs.ElementType != ElementType.Hidden)
                                           .OrderBy(x => x.ControlSpecs.Order);

                    // loop over the attributes (ordered)..
                    foreach (var formElement in elementsToRender)
                    {
                        sb.Append(this.RenderElement(formElement, formBuilderParameters));
                    }
                }
                sb.Append(this.layoutBuilder.EndFieldCollection(formBuilderParameters));
            }

            return(sb.ToString());
        }
Beispiel #4
0
        public string BuildForm(List<FormElement> formElements, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            sb.Append(RenderHiddenFields(formElements));
               
            var groupsofElements = formElements.OrderBy(x => x.ControlSpecs.GroupName).GroupBy(x => x.ControlSpecs.GroupName);
            var useLegend = (formElements.Select(x => x.ControlSpecs.GroupName).Distinct().Count() > 1);

            foreach (var groupedElements in groupsofElements)
            {
                var groupName = (!String.IsNullOrEmpty(groupedElements.Key)) ? groupedElements.Key : "General";

                sb.Append(this.layoutBuilder.BeginFieldCollection(groupName, useLegend, formBuilderParameters));
                {
                    var elementsToRender = groupedElements.Where(x => x.ControlSpecs.ElementType != ElementType.Hidden)
                                                          .OrderBy(x => x.ControlSpecs.Order);

                    // loop over the attributes (ordered)..
                    foreach (var formElement in elementsToRender)
                    {
                       sb.Append(this.RenderElement(formElement, formBuilderParameters));
                    }
                }
                sb.Append(this.layoutBuilder.EndFieldCollection(formBuilderParameters));
               
            }

            return sb.ToString();
        }
Beispiel #5
0
        public string EndElementContainer(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter   = new HtmlTextWriter(stringWriter);

            ElementContainer.End(textWriter);
            return(sb.ToString());
        }
Beispiel #6
0
        public string EndElementContainer(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter = new HtmlTextWriter(stringWriter);

            ElementContainer.End(textWriter);
            return sb.ToString();
        }
Beispiel #7
0
        public string BeginFieldCollection(string groupName, bool useLegend, IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter   = new HtmlTextWriter(stringWriter);

            FieldCollection.Begin(textWriter, groupName, useLegend);

            return(sb.ToString());
        }
Beispiel #8
0
        public string EndFieldCollection(IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter   = new HtmlTextWriter(stringWriter);

            FieldCollection.End(textWriter);

            return(sb.ToString());
        }
Beispiel #9
0
        public string EndFieldCollection(IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter = new HtmlTextWriter(stringWriter);

            FieldCollection.End(textWriter);

            return sb.ToString();
        }
Beispiel #10
0
        public string BeginFieldCollection(string groupName, bool useLegend, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter = new HtmlTextWriter(stringWriter);

            FieldCollection.Begin(textWriter, groupName, useLegend);
            
            return sb.ToString();
        }
        public void BeginElementContainer(HtmlTextWriter contextWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            this.elementContainerWriter = contextWriter;
            this.elementContainerWriter.AddAttribute(HtmlTextWriterAttribute.Class, "form-group");

            if (formElement != null && formElement.HasErrors)
            {
                elementContainerWriter.AddAttribute(HtmlTextWriterAttribute.Class, Foundation.Web.Configurations.WebConfigurations.HasErrorsCssClass);
            }

            elementContainerWriter.RenderBeginTag(HtmlTextWriterTag.Div); // div (ElementType-Group)
        }
Beispiel #12
0
        public string BeginControlContainer(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter   = new HtmlTextWriter(stringWriter);

            var bootStrapBuilderParameters = (BuilderParameters)formBuilderParameters;
            var formType = bootStrapBuilderParameters.FormType;

            ControlContainer.Begin(textWriter, formType);

            return(sb.ToString());
        }
        public void BeginControlContainer(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var bootStrapBuilderParameters = (BootStrapBuilderParameters) formBuilderParameters;
            var formType = bootStrapBuilderParameters.FormType;
            if (formType == BootstrapFormType.Horizontal)
            {
                // Controls Div
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-9");
            }

            textWriter.RenderBeginTag(HtmlTextWriterTag.Div);
            
        }
        public void BeginFieldCollection(string groupName, bool useLegend, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            this.collectionWriter = contextWriter;
            collectionWriter.RenderBeginTag(HtmlTextWriterTag.Fieldset); // start field set

            // if at least one group name is there , then use legend (field container)

            if (useLegend)
            {
                collectionWriter.RenderBeginTag(HtmlTextWriterTag.Legend); // start legend tag
                collectionWriter.Write(groupName);
                collectionWriter.RenderEndTag(); // legend
            }
        }
Beispiel #15
0
        public void BeginFieldCollection(string groupName, bool useLegend, IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);

            this.collectionWriter = contextWriter;
            collectionWriter.RenderBeginTag(HtmlTextWriterTag.Fieldset); // start field set

            // if at least one group name is there , then use legend (field container)

            if (useLegend)
            {
                collectionWriter.RenderBeginTag(HtmlTextWriterTag.Legend); // start legend tag
                collectionWriter.Write(groupName);
                collectionWriter.RenderEndTag();                           // legend
            }
        }
Beispiel #16
0
        public string RenderElement(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();

            sb.Append(this.layoutBuilder.BeginElementContainer(formElement, formBuilderParameters));
            {
                sb.Append(this.layoutBuilder.RenderLabel(formElement, formBuilderParameters));
                sb.Append(this.layoutBuilder.BeginControlContainer(formElement, formBuilderParameters));
                {
                    var elementBlock = this.elementGenerator.RenderElement(formElement);

                    elementBlock.MergeAttributes(formElement.ValidationAttributes);

                    sb.Append(elementBlock);
                }
                sb.Append(this.layoutBuilder.EndControlContainer(formElement, formBuilderParameters));
            }
            sb.Append(this.layoutBuilder.EndElementContainer(formElement, formBuilderParameters));

            return(sb.ToString());
        }
Beispiel #17
0
        public string RenderElement(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            
            sb.Append(this.layoutBuilder.BeginElementContainer(formElement, formBuilderParameters));
            {
                sb.Append(this.layoutBuilder.RenderLabel(formElement, formBuilderParameters));
                sb.Append(this.layoutBuilder.BeginControlContainer(formElement, formBuilderParameters));
                {
                    var elementBlock = this.elementGenerator.RenderElement(formElement);

                    elementBlock.MergeAttributes(formElement.ValidationAttributes);
                    elementBlock.MergeAttributes(formElement.AppendedHtmlAttributes);

                    sb.Append(elementBlock);
                }
                sb.Append(this.layoutBuilder.EndControlContainer(formElement, formBuilderParameters));
            }
            sb.Append(this.layoutBuilder.EndElementContainer(formElement, formBuilderParameters));

            return sb.ToString();
        }
 public void EndFieldCollection(IFormBuilderParameters formBuilderParameters)
 {
     this.collectionWriter.RenderEndTag(); // div (field set)
 }
Beispiel #19
0
        public string BeginControlContainer(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter = new HtmlTextWriter(stringWriter);
 
            var bootStrapBuilderParameters = (BuilderParameters) formBuilderParameters;
            var formType = bootStrapBuilderParameters.FormType;
            ControlContainer.Begin(textWriter, formType);

            return sb.ToString();
        }
Beispiel #20
0
 public void EndFieldCollection(IFormBuilderParameters formBuilderParameters)
 {
     this.collectionWriter.RenderEndTag(); // div (field set)
 }
Beispiel #21
0
        public void BeginElementContainer(HtmlTextWriter contextWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            this.elementContainerWriter = contextWriter;
            this.elementContainerWriter.AddAttribute(HtmlTextWriterAttribute.Class, "form-group");

            if (formElement != null && formElement.HasErrors)
            {
                elementContainerWriter.AddAttribute(HtmlTextWriterAttribute.Class, Foundation.Web.Configurations.WebConfigurations.HasErrorsCssClass);
            }

            elementContainerWriter.RenderBeginTag(HtmlTextWriterTag.Div); // div (ElementType-Group)
        }
 public void EndControlContainer(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
 {
     textWriter.RenderEndTag(); // div (ElementType-Group)
 }
 public void EndElementContainer(HtmlTextWriter textWriter, IFormBuilderParameters formBuilderParameters)
 {
     this.elementContainerWriter.RenderEndTag(); // div (ElementType-Group)
 }
Beispiel #24
0
 public void EndElementContainer(HtmlTextWriter textWriter, IFormBuilderParameters formBuilderParameters)
 {
     this.elementContainerWriter.RenderEndTag(); // div (ElementType-Group)
 }
Beispiel #25
0
        public void BeginControlContainer(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var bootStrapBuilderParameters = (BootStrapBuilderParameters)formBuilderParameters;
            var formType = bootStrapBuilderParameters.FormType;

            if (formType == BootstrapFormType.Horizontal)
            {
                // Controls Div
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-9");
            }

            textWriter.RenderBeginTag(HtmlTextWriterTag.Div);
        }
Beispiel #26
0
 public void EndControlContainer(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
 {
     textWriter.RenderEndTag(); // div (ElementType-Group)
 }