Bitrix Site Manager

CForm::GetBySID

record set
CForm::GetBySID(
 varchar(255) SID
);

The function returns the selection from the database containing the form parameters.

Parameters

ParameterDescription
SID Symbolic ID of a form.

Return Values

Returns a database record containing the form parameters. See Example for details on handling the result.

Example

The following is an example of one row of the selection returned by CForm::GetBySID.


Array
(
    [ID] => 1 (ID)
    [TIMESTAMP_X] => 22.09.2003 16:52:48 (modification date)
    [NAME] => College application form
    [VARNAME] => COLLEGE (identifier)
    [BUTTON] => Save (button title for the template default.php)
    [C_SORT] => 100 (sort weight)
    [LID] => en (site)
    [IMAGE_ID] => (ID of the image)
    [DESCRIPTION] => (description)
    [DESCRIPTION_TYPE] => html (type of description)
    [SHOW_TEMPLATE] => osago.php (form display template)
    [MAIL_EVENT_TYPE] => FORM_FILLING_COLL (mail event type)
    [MAIL_TEMPLATE] => 270 (ID of the mail template)
    [SHOW_RESULT_TEMPLATE] => default.php (result display template)
    [PRINT_RESULT_TEMPLATE] => cprint.php (result print template)
    [EDIT_RESULT_TEMPLATE] => default.php (result editing temlate)
    [FILTER_RESULT_TEMPLATE] => name of the file containing 
                                the code used for filter display
    [TABLE_RESULT_TEMPLATE] => name of the file containing 
                               the code used to display results
    [STAT_EVENT1] => (event type identifier - event1)
    [STAT_EVENT2] => (event type identifier - event2)
    [STAT_EVENT3] => (auxiliary event type identifier - event3)
    [C_FIELDS] => 2 (number of form fields)
    [QUESTIONS] => 59 (number of questions in the form)
)

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");
?>