user1269310
user1269310

Reputation: 342

Programmatically accessing Kentico alternative forms properties

In Kentico 7, I'm trying to perform actions based on what alternative form is being submitted.

public partial class CMSModuleLoader
{
    private class ObjectEventsAttribute : CMSLoaderAttribute
    {
        public override void Init()
        {
            ObjectEvents.Insert.Before += My_Create_Account_Page;

        }

        private void My_Create_Account_Page(object sender, ObjectEventArgs e)
        {
            if (e.Object is BizFormItem && e.Object != null)
            {
                BizFormItem formEntry = (BizFormItem)e.Object;

                BizFormInfo form = formEntry.BizFormInfo;

                if (form.FormName == "MyOpenAccount")
                {
                    // somehow determine which alternative form this is

                    // do stuff with the fields in that alternative form
                }
            }
        }
    }
}

I've been up and down the documentation and found no solution. I could add a field that I would give a default value of the alt. form name, but that opens me up to editors deleting that field, and it still doesn't tell me what other fields are in the alternative form. Any other ideas?

Upvotes: 1

Views: 529

Answers (1)

mivra
mivra

Reputation: 1400

I'm afraid that alternative form name is not accessible if you use ObjectEvents approach. But the information is known by the "Online form" (BizForm) webpart. So you probably have to customize it or create a copy. Bizform control has AlternativeFormFullName property and you can hook on one of its events like OnAfterSave.

Upvotes: 1

Related Questions