On-line Form Questions

Luke Tappin asked on August 29, 2014 14:46

I'm having a few problems using the 'On-line Form' Web Part:

  1. When using the form, the user must first select an option from a drop-down list; depending on what option is chosen, only certain fields will be displayed. All shown fields are required, but the problem is that the hidden fields are also required as far as the form is concerned - how do I modify the form to ignore validation requirements of fields that are not visible?

  2. How do I include the submitting user's username into the email sent upon the form's completion?

  3. How do I make a checkbox required, so that it has to be ticked?

Thank you in advance for any assistance with any of the above questions.

Recent Answers


Richard Sustek answered on September 15, 2014 14:54

Hi Luke,

Thank you for your message.

1) Since you haven't mentioned your version and based on your question I'm assuming you are Kentico 7. In version 7 the validation takes places even if the field is not visible and unfortunately there is no workaround for this apart of creating a new custom form control as per -

devnet.kentico.com/docs/7_0/devguide/developing_form_controls.htm

In Kentico 8 this feature has been addressed and it works the way you want by default so that validation will take in place only if the field is visible on the form.

2) If you want to add a current user's username to the Notification e-mail you can simply use macro like: {% CurrentUser.UserName #%}

In Layout of notification e-mail you can use any macro or K# you like. You can even use custom macros if you like.

3) By default checkbox control cannot be set like this but you can make very simply modification to the Check box form control which will enable you this. You can go to Development -> Form controls and clone Check box control. Then add a validation method for it like:

  public override bool IsValid()
    {
        if (checkbox.Checked){
            return true;
        }
        else
        {
            // Set form control validation error message.
            this.ValidationError = "You need to agree to continue";
            return false;
        }

With this modificatio it will work as a confirmation button.

Let us know if you need anything else.

Kind regards,

Richard Sustek

0 votesVote for this answer Mark as a Correct answer

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