/// <summary> /// In HTML konvertieren /// </summary> /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param> /// <returns>Das Control als HTML</returns> public override IHtmlNode Render(RenderContext context) { var renderContext = new RenderContextFormular(context, this); var formName = $"form_{ Name }"; Initialize(context); (Items as List <ControlFormularItem>).ForEach(x => x.Initialize(renderContext)); OnInitialize(); SubmitButton.Initialize(renderContext); // Prüfe ob Formular abgeschickt wurde -> Fomular mit Daten füllen if (!context.Page.HasParam(formName)) { OnFill(); } PreProcess(renderContext); var button = SubmitButton.Render(renderContext); var html = new HtmlElementFormForm() { ID = ID, Class = Css.Concatenate("form-inline", GetClasses()), Style = GetStyles(), Role = Role, Name = Name.ToLower() != "form" ? "form_" + Name.ToLower() : Name.ToLower(), Action = Uri?.ToString(), Method = "post", Enctype = TypeEnctype.None }; html.Elements.Add(new ControlFormularItemInputHidden(formName) { Value = Name }.Render(renderContext)); foreach (var item in Items) { if (item is ControlFormularItemInput input) { var icon = new ControlIcon() { Icon = input?.Icon }; var label = new ControlFormularItemLabel(!string.IsNullOrEmpty(item.ID) ? item.ID + "_label" : string.Empty); var help = new ControlFormularItemHelpText(!string.IsNullOrEmpty(item.ID) ? item.ID + "_help" : string.Empty); var fieldset = new HtmlElementFormFieldset() { Class = "form-group" }; label.Initialize(renderContext); help.Initialize(renderContext); label.Text = context.I18N(input?.Label); label.FormularItem = item; label.Classes.Add("mr-2"); help.Text = context.I18N(input?.Help); help.Classes.Add("ml-2"); if (icon.Icon != null) { icon.Classes.Add("mr-2 pt-1"); fieldset.Elements.Add(new HtmlElementTextSemanticsSpan(icon.Render(renderContext), label.Render(renderContext)) { Style = "display: flex;" }); } else { fieldset.Elements.Add(label.Render(renderContext)); } fieldset.Elements.Add(item.Render(renderContext)); if (input != null) { fieldset.Elements.Add(help.Render(renderContext)); } html.Elements.Add(fieldset); } else { html.Elements.Add(item.Render(context)); } } html.Elements.Add(button); return(html); }