November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
This is a great idea and also possible if you create your a custom Wrapping Forms Container Block.
Have a look at this commit whch adds the files for a custom Forms container: Custom DataCaptureForm Container block with razor template · johnnymullaney/Foundation@2fdb719 (github.com)
What I've attempted so far is the create a new form, update its ElementsArea with the elements from the new form, and updated its steps with the elements from the new form as well. The added fields render on the page, but on submission, the submission data does not contain the new items. Any advice?
public override ActionResult Index(ILeadCallToActionButtonBlock currentBlock)
{
var baseForm = _contentLoader.Get<ExtendedFormContainerBlock>(currentBlock.LeadBaseForm).CreateWritableClone() as ExtendedFormContainerBlock;
var addOnForm = _contentLoader.Get<ExtendedFormContainerBlock>(currentBlock.LeadFormSpecificElements?.Items[0]?.ContentLink);
foreach (var addOnItem in addOnForm.ElementsArea.Items)
{
baseForm.ElementsArea.Items.Add(new ContentAreaItem()
{ ContentLink = addOnItem.ContentLink });
}
var baseFormLastStep = baseForm.Form.Steps.Last();
var baseFormLastStepElements = baseFormLastStep.Elements;
var addOnFormElements = addOnForm.Form.Steps.First().Elements.ToList();
foreach (var addOnFormElement in addOnFormElements)
{
addOnFormElement.Form = baseForm.Form;
}
var combinedElements = baseFormLastStepElements?.Concat(addOnFormElements);
var newForm = baseForm.Form.Steps;
newForm.Last().Elements = combinedElements;
baseFormLastStep.Elements = newForm;
var viewModel = new LeadCallToActionButtonViewModel
{
LeadForm = baseForm,
ButtonColor = currentBlock.Color,
ButtonText = currentBlock.ButtonText,
TopText = currentBlock.TopText,
Image = currentBlock.Image,
Anchor = currentBlock.Anchor,
Id = new Guid()
};
base.Index(currentBlock);
return PartialView(viewModel);
}
Our site has around 80 forms. These forms have a lot of "standard" form elements that are the same across each form (name, phone number, email etc.).
Is it possible to have an editor-editable "base form" as a settings object, that the editor can then extend with additional form elements on pages that require it? And importan caveat is that if an editor changes the base form, this change should be reflected in all other forms, that utilize the base form as its template. Is this possible? Thanks!
Base form in settings-block:
Form 1:
Form 2:
Editor changes the base form to:
Base form in settings-block:
So Form 1 now looks like:
Form 1: