Bitrix Site Manager

CForm::SetEvent

CForm::SetEvent(
 int RESULT_ID,
 varchar(255) EVENT1=false,
 varchar(255) EVENT2=false,
 varchar(255) EVENT3=false
);

Registers a new event in the Statistics module.

Parameters

ParameterDescription
RESULT_ID Result ID.
EVENT1 Event type identifier event1. If this parameter is not specified, the default value assigned to the form is used. If the form has no default event1 identifier, the "form" value is used.
EVENT2 Event type identifier event2. If this parameter is not specified, the default value assigned to the form is used. If the form has no default event2 identifier, the form identifier value is used.
EVENT3 Event type identifier event3. If this parameter is not specified, the default value assigned to the form is used. If the form has no default event3 identifier, the link to the result view page is used.

Example

The below example shows the sample file "form_fill.php" displaying the form.



<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
if (CModule::IncludeModule("form"))
{
    if (intval($WEB_FORM_ID)>0) 
        $z = <b>CForm::GetByID</b>($WEB_FORM_ID); 
    else 
        $z = CForm::GetBySID($WEB_FORM_NAME);

    if (!($zr=$z->Fetch())) 
    {
        $FORM_EXIST = "N";
        $strError .= "Invalid form ID.<br>";
    }
    else
    {
        $FORM_EXIST = "Y";
        $WEB_FORM_ID = $zr["ID"];
        $WEB_FORM_NAME = $zr["VARNAME"];
        if ($REQUEST_METHOD=="POST" && 
            intval($WEB_FORM_ID)>0 && 
            strlen($web_form_submit)>0)
        {
            $arrVALUES = $HTTP_POST_VARS;
            $error = CForm::Check($WEB_FORM_ID);
            if (strlen($error)<=0)
            {
                if ($RESULT_ID = CFormResult::Add($WEB_FORM_ID))
                {
                    $arr = CFormResult::GetDataByID($RESULT_ID, array("VS_PHOTO"));
                    $PHOTO_EXIST = (intval($arr["VS_PHOTO"][0]["USER_FILE_ID"])>0) ? "Y" : "N";
                    CFormResult::SetField($RESULT_ID, "VS_PHOTO_EXIST", $PHOTO_EXIST);
                    CForm::SetEvent($RESULT_ID);
                    CForm::Mail($RESULT_ID);
                    LocalRedirect("index.php?WEB_FORM_NAME=".$WEB_FORM_NAME. "&strNote=".urlencode("information saved"));
                }
            }
            else 
                $strError .= $error;
        }
    }
}

if (strlen($APPLICATION->GetTitle()) <= 0)
    $APPLICATION->SetTitle("Visitor survey");

require_once ($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_after.php");
echo ShowNote($strNote);
echo ShowError($strError);
?><?
if (CModule::IncludeModule("form"))
    CForm::Show($WEB_FORM_NAME, $arrVALUES); 
require_once ($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog.php");
?>