Hide submit button in bizform

Romina Herrera asked on March 22, 2018 16:55

I am using a bizform with many fields that have visibility conditions, some of the fields direct users to other areas of the website.

As such, having the "submit" button always present at the bottom of the form, results in a confusing user experience.

How can I hide the button, possibly relying on the same visibility conditions that other fields use?

Recent Answers


Peter Mogilnitski answered on March 22, 2018 17:09 (last edited on March 22, 2018 17:35)

Not "out of the box". The easiest way would to have your own javascript/juqery that will hide the button based on some inputs values.

0 votesVote for this answer Mark as a Correct answer

Romina Herrera answered on March 22, 2018 19:29

Hi Peter, what about the bizform code window that is available in the Forms application? could it be accomplished by editing there?

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on March 23, 2018 13:55 (last edited on March 23, 2018 14:30)

I would do it in your biz form layout with javascript/jquery, this way javascript will be specific to your biz form, but yes sure you can do in bizform web part (CMSWebParts/BizForms/bizform.ascx), for example in

protected void SetupControl():

{
    if (StopProcessing)
    {
        // Do nothing
        viewBiz.StopProcessing = true;
    }
    else
    {
        // Set BizForm properties
        viewBiz.FormName = BizFormName;
        viewBiz.SiteName = SiteName;
        viewBiz.UseColonBehindLabel = UseColonBehindLabel;
        viewBiz.AlternativeFormFullName = AlternativeFormName;
        viewBiz.ValidationErrorMessage = ValidationErrorMessage;

        if (BizFormName == "yourformname")
        {
            bool isSubmitButtonVisible = true;

            var visibleFields  = viewBiz.FormInformation.GetFields(true, false);
            foreach (FormFieldInfo field in visibleFields)
            {
                var disyplayName = field.GetDisplayName(MacroResolver.GetInstance());
                //... make your condition
                isSubmitButtonVisible = false;
            }
            var invisibleFields = viewBiz.FormInformation.GetFields(false, true);
            foreach (FormFieldInfo field in invisibleFields)
            {
                var disyplayName = field.GetDisplayName(MacroResolver.GetInstance());
                //...make your condition
                isSubmitButtonVisible = false;
            }

            viewBiz.SubmitButton.Visible = isSubmitButtonVisible;
        }
        ...

P.S. If you want do in the web part I would recommend to clone it, so changes will not accidentally affect other biz forms

0 votesVote for this answer Mark as a Correct answer

Eric Dugre answered on March 23, 2018 20:17

Romina,

It is possible to hide the Submit button of a BizForm using a custom layout: https://docs.kentico.com/k11/managing-website-content/forms/defining-custom-form-layout. In a custom layout, you can add the $$submitbutton$$ macro to place the button in a particular location, so it would be possible to place it within a <div> element that is hidden via CSS.

However, it isn't possible to dynamically show/hide the button using the same approach as form fields. This would require some javascript, or customization of the web part as Peter suggested. Of course, we would recommend that you create a custom web part by cloning the original web part first.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.