November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi Eric,
I'm inclined to agree with Quan in that the scenario should really be covered by validation however, if you want add the dependencies tab to the submit button it is possible though with a big caveat that you'd need to implement an interface which is in an internal namespace (EPiServer.Forms.Core.Internal.Dependency). This means that this sits outside of the standard semantic versioning and may contain breaking changes in a minor verion update. If that's a risk you're willing to accept, you could create your own version of SubmitButtonElementBlock inheriting from SubmitButtonElementBlock and implementing IMultipleConditionsElementDependant which provides the relevant fields to pick your dependencies and act on them in the JavaScript.
[ContentType(GUID = "A957C10C-E2B7-492B-96A2-1CA3699A479E", GroupName = "ActionElements", Order = 3200)]
public class HideableSubmitElementBlock : SubmitButtonElementBlock, IMultipleConditionsElementDependant
{
[Display(GroupName = "Dependencies", Order = 1000)]
[SelectOne(SelectionFactoryType = typeof(DependencyActionSelectionFactory))]
public virtual string SatisfiedAction { get; set; }
[Display(GroupName = "Dependencies", Order = 2000)]
[SelectOne(SelectionFactoryType = typeof(ConditionCombinationSelectionFactory))]
public virtual int ConditionCombination { get; set; }
[BackingType(typeof(PropertyDependencyConditionsList))]
[CircularDependencyValidation(ErrorMessage = "/episerver/forms/contentediting/validation/circulardependency")]
[Display(GroupName = "Dependencies", Order = 3000)]
public virtual IEnumerable<ICondition> Conditions { get; set; }
}
You'll then need to add a view for that block which you can copy from \modules\_protected\EPiServer.Forms\EPiServer.Forms.zip\Views\ElementBlocks\SubmitButtonElementBlock.ascx into \Views\Shared\ElementBlocks\HideableSubmitElementBlock.ascx. The only changes you'll need to make is to change the name attribute of the <button> to be <%: formElement.ElementName %> then wrap it in a div with a few attributes as below:
<%@ Import Namespace="System.Web.Mvc" %>
<%@ Import Namespace="EPiServer.Forms.Implementation.Elements" %>
<%@ Control Language="C#" Inherits="ViewUserControl<SubmitButtonElementBlock>" %>
<%
var formElement = Model.FormElement;
var buttonText = Model.Label;
var buttonDisableState = Model.GetFormSubmittableStatus(ViewContext.Controller.ControllerContext.HttpContext);
%>
<div class="FormSubmitButton" data_f_type="submitbutton" data-f-element-name="<%: formElement.ElementName %>">
<button id="<%: formElement.Guid %>" name="<%: formElement.ElementName %>" type="submit" value="<%: formElement.Guid %>" data-f-is-finalized="<%: Model.FinalizeForm.ToString().ToLower() %>"
data-f-is-progressive-submit="true" data-f-type="submitbutton"
<%= Model.AttributesString %> <%: buttonDisableState %>
<% if (Model.Image == null)
{ %>
class="Form__Element FormExcludeDataRebind FormSubmitButton">
<%: buttonText %>
<% } else { %>
class="Form__Element FormExcludeDataRebind FormSubmitButton FormImageSubmitButton">
<img src="<%: Model.Image.Path %>" data-f-is-progressive-submit="true" data-f-is-finalized="<%: Model.FinalizeForm.ToString().ToLower() %>" />
<% } %>
</button>
</div>
You should then be able to create a HideableSubmit button which will act like a standard submit button but with the option to add depencencies.
Hi Eric and Paul,
It seems that hiding/showing SubmitButton/RichEtextElement is useful in some cases.
This will be available in the next version.
Is there a way to disable/hide the submit button until all fields are filled in? With the latest forms update, the Dependencies tab shows up on all the form fields but the submit button. Is this something that was omitted intentionally, or should I be seeing this tab on the submit configuration as well?