protected dynamic BuildForms(ElementEditorContext context) { // TODO: Fix Forms API so that it works with prefixes. Right now only binding implements prefix, but building a form ignores the specified prefix. // If not a post-back, we need to bind the form with the element's data values. Otherwise, bind the form with the posted values. var valueProvider = context.Updater == null ? context.Element.Data.ToValueProvider(_cultureAccessor.CurrentCulture) : context.ValueProvider; var forms = FormNames.Reverse().Select(x => { var shape = _formManager.Bind(_formManager.Build(x), valueProvider); if (context.Updater != null) { // Update the element's data dictionary with the posted values. Action <object> process = s => UpdateElementProperty(s, context); FormNodesProcessor.ProcessForm(shape, process); } return(shape); }).ToArray(); var formShape = context.ShapeFactory.ElementEditor__Forms(Forms: forms); return(formShape); }
protected dynamic BuildForm(ElementEditorContext context, string formName, string position = null) { // TODO: Fix Forms API so that it works with prefixes. Right now only binding implements prefix, but building a form ignores the specified prefix. // If not a post-back, we need to bind the form with the element's data values. Otherwise, bind the form with the posted values. var valueProvider = context.Updater == null ? context.Element.Data.ToValueProvider(_cultureAccessor.CurrentCulture) : context.ValueProvider; var form = _formManager.Bind(_formManager.Build(formName), valueProvider); if (context.Updater != null) { // Update the element's data dictionary with the posted values. Action <object> process = s => UpdateElementProperty(s, context); FormNodesProcessor.ProcessForm(form, process); } if (!String.IsNullOrWhiteSpace(position)) { form.Metadata.Position = position; } return(form); }