Forms Module Notification - General Discussions - General Discussions - Progress Community
 General Discussions

Forms Module Notification

  • Forms Module Notification
  • Hi there,
    I figured out, that currently there is no possibility to send a notification via email or even the whole content of a submitted form, created with the forms module. Will this feature be available in the final version or in one of the weekly builds?

    Regards,
    Patrick
  • Hello Pat,

    Currently the only way to create notification for a forum is creating a custom control that inherits from FormsControl where you have access to the submit button and its click event

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Telerik.Sitefinity.Modules.Forms.Web.UI;
    using Telerik.Sitefinity.Modules.Forms.Web.UI.Fields;
    using Telerik.Web.UI;
     
    namespace Telerik.Sitefinity.Samples
        public class FormsControlCustom : FormsControl
        
            protected override string LayoutTemplateName
            
                get
                
                    return FormsControlCustom.layoutTemplateName;
                
            
     
            protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
            
         
                base.InitializeControls(container);
            
            protected override void ConfigureSubmitButton(System.Web.UI.Control control, string validationGroup)
            
                var submit = control as FormSubmitButton;
                submit.Click += new EventHandler(submit_Click);
                base.ConfigureSubmitButton(control, validationGroup);
            
     
            void submit_Click(object sender, EventArgs e)
            
                 
            
     
     
         
     
            private const string layoutTemplateName = "Telerik.Sitefinity.Samples.Resources.FormsControl.ascx";
     
        

    Forms is included in the workflow and this is something that we will do on a later stage and we have to discuss  internally the time frame for this implementation. Forms notification will not be included for the official release.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • Hello Ivan,
    thank you for your answer. Could you please be a bit more specific how to implement that custom control?
    I examined jobs and newsrotator control, but I still have some questions/problems to start.
    Can I use the from DefaultControlTemplates.zip?
    Do I need to create more ascx file(s)?
    How can I access the controls (textboxes, checkboxes...) in the form.
    Thank you very much.

    Regards,
    Patrick
  • Hello Pat,

    The code below should be added to a class library and you have to use the template below as an embedded resource

    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="sfFields" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.Fields" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
     
    <sfFields:FormManager id="formManager" runat="server" />
     
     
    <asp:Panel ID="errorsPanel" runat="server" CssClass="sfErrorSummary" />
    <sf:SitefinityLabel id="successMessage" runat="server" WrapperTagName="div" HideIfNoText="true" CssClass="sfSuccess" />
    <asp:Panel ID="formControls" runat="server">
         
    </asp:Panel>

    Inside FormsControlCustom you have access to
    • FormId
    • FormName

    you can use FormsManager and its GetForm method where you can pass this.FormId which will return you the FormDescription. From FormDescription object you can access the form controls and all public properties.

    FormsControlCustom  will be used as the build in forms control - "Submit button" . By default the submit button of each form is dynamically generated.

    The custom control have to be registered inside Sitefinity/Administration/Settings/Advanced

    Toolboxes >> Toolboxes >> FormControls >> Sections >> Commmon >> Tools

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • 238882_formsmodul.JPG
    Hi Ivan,
    I added a custom control with vb code
    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Text
    Imports Telerik.Sitefinity.Modules.Forms.Web.UI
    Imports Telerik.Sitefinity.Modules.Forms.Web.UI.Fields
    Imports Telerik.Sitefinity.Modules.Forms
    Imports Telerik.Sitefinity.Modules.Forms.FormsModule
    Imports Telerik.Sitefinity.Forms
    Imports Telerik.Sitefinity.Forms.Model
    Imports Telerik.Web.UI
     
    Namespace FormsNotification
        Public Class FormsControlCustom
            Inherits FormsControl
            Private Const m_layoutTemplateName As String = "FormsNotification.Resources.Views.FormsControl.ascx"
            Protected Overrides ReadOnly Property LayoutTemplateName() As String
                Get
                    Return m_layoutTemplateName
                End Get
     
            End Property
     
            Protected Overrides Sub InitializeControls(ByVal container As Global.Telerik.Sitefinity.Web.UI.GenericContainer)
     
                MyBase.InitializeControls(container)
            End Sub
            Protected Overrides Sub ConfigureSubmitButton(ByVal control As System.Web.UI.Control, ByVal validationGroup As String)
                Dim submit = TryCast(control, FormSubmitButton)
                AddHandler submit.Click, AddressOf Submit_Click
                MyBase.ConfigureSubmitButton(control, validationGroup)
            End Sub
     
            Private Sub submit_Click(ByVal sender As Object, ByVal e As EventArgs)
                Dim myFormName As String = FormName
                Dim myFormID As Guid = FormId
                Dim fm As New FormsManager
                Dim fd As FormDescription = fm.GetForm(myFormID)
                Dim s As String = myFormName
     
            End Sub
        End Class
    End Namespace

    Also added ascx with build action Embedded Resource.
    I registered the control in Sitefinity but ended up with a failure message.
    Type "FormsNotification.FormsControlCustom" cannot be resolved.

    What am I supposed to write in the ControlType field? Please see attached screenshot.

    Regards,
    Patrick
  • Hi Pat,

    You should type the assembly name as well, separated with a comma from the namespace. You can check some of the other controls like ConentBlock and its settings.

    sample

    FormsNotification.FormsControlCustom, FormsNotification

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • Hi Ivan,
    my assembly name is, as you assume, FormsNotification.
    I added it, but it is not resolved yet.
    Now it is Type "FormsNotification.FormsControlCustom, FormsNotification" cannot be resolved.
    FormsNotification.dll of course is in BIN folder.

    Btw, in the jobs module example documentation is no assembly name mentioned for ControlType.

    Regards,
    Patrick
  • Hello Pat,

    If you still get this error than the namespace or assembly name is not correct. Please check any of the other controls like ContentBlock to see how it is registered. There is no better sample that looking at the registration of an existing control.

    Some of the existing controls use the following properties, but they are not required.

    • Version
    • Culture
    • PublicKeyToken

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • I need this functionality as well.  Is there a full working sample of how to implement this?

    Dallas
  • Hi Dallas,

    What is the problem with the sample code provided above by me? FormsControlCustom  is a fully working sample. You only need to add it to your solution as a class library and set the proper references.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • I got it working eventually. 

    ty
    Dallas
  • I need this functionality as well as i need to email the form responses upon submission.  I got everything working and compiling based on the code above.  I want to make sure i'm implementing it right.  What i've done is created a 2nd form that only has this custom form control on it. I delete the auto generated submit button from this form.  Then i select my other form through this custom control and then display that form on a webpage?  Is that correct?  Do i have to create double the amount of forms just to be able to have this submit button functionality. 
  • Hi ,

    The custom control inherits from FormsControl which shows the entire form and generates the "submit" button on the fly. FormsControl has a selector that you can use to choose a form. Actually all you have to do is to override ConfigureSubmitButton ( the method that configure the button in the base class) and subscribe for the click event. No other changes are needed to send a notification.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • could you provide sample code for looping though all the controls in the form? 

    i have this already

     FormsManager fm = new FormsManager();

     FormDescription fd = fm.GetForm(FormId);

    but not sure how to get the controls from there.