Bitrix Site Manager

CForm::ShowResult

CForm::ShowResult(
 int RESULT_ID,
 varchar(255) TEMPLATE="",
 varchar TEMPLATE_TYPE="show",
 char(1) SHOW_ADDITIONAL="N",
 char(1) SHOW_ANSWER_VALUE="Y",
 char(1) SHOW_STATUS="N"
);

The method emits the HTML code displaying the result using either display or print template.

Parameters

ParameterDescription
RESULT_ID Result ID.
TEMPLATE Name of the template file.
TEMPLATE_TYPE Template type: "show" - result view template, "print" - result print template.
SHOW_ADDITIONAL If set to "Y", values of the form fields are included in output. Otherwise, only answers to the form questions are displayed.
SHOW_ANSWER_VALUE If set to "Y", templates like default.php will display values ANSWER_VALUE רע round brackets.
SHOW_STATUS If set to "Y", templates like default.php will include result status in the results table.

Example

The below example shows the sample file "form_view.php" used to display the result.



<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/form/include.php");
include(GetLangFileName($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/form/admin/lang/", "/form_result_view.php"));
$APPLICATION->SetTitle(str_replace("#RESULT_ID#","$RESULT_ID","View form # #RESULT_ID#"));
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_after.php");
?>
<?
$z = CFormResult::GetByID($RESULT_ID);
if ($arrResult = $z->Fetch()) :

    ?><a href="index.php?web_form_name=<?=$zr["varname"]?>" class="navchain">Forms
<?
    echo ShowError($strError);
    echo ShowNote($strNote);

    $F_RIGHT = CAllForm::GetPermission($arrResult["FORM_ID"]);

?>
<br>
<table cellspacing="0" cellpadding="2">
    <?if ($F_RIGHT>=25):?>
    <tr>
        <td align="right" valign="top"><font class="tablebodytext"><b>ID:</b></font></td>
        <td valign="top"><font class="tablebodytext"><?=$arrResult["ID"]?></font></td>
    </tr>
    <tr>
        <td align="right" valign="top"><font class="tablebodytext"><b><?=GetMessage("FORM_FORM_NAME")?></b></font></td>
        <td valign="top"><font class="tablebodytext"><?
        echo "[<a class='tablebodylink' href='form_edit.php?lang=".lang."&id=".$arrresult["form_id"]."'>". $arrResult["FORM_ID"]."</a>] (".$arrResult["VARNAME"].") ".$arrResult["NAME"];
        ?></font></td>
    </tr>
    <?endif;?>
    <tr>
        <td align="right" valign="top"><font class="tablebodytext"><b><?=GetMessage("FORM_DATE_CREATE")?></b></font></td>
        <td valign="top"><font class="tablebodytext"><?=$arrResult["DATE_CREATE"]?></font></td>
    </tr>
    <tr>
        <td align="right" valign="top"><font class="tablebodytext"><b><?=GetMessage("FORM_TIMESTAMP")?></b></font></td>
        <td valign="top"><font class="tablebodytext"><?=$arrResult["TIMESTAMP_X"]?></font></td>
    </tr>
    <?if ($F_RIGHT>=25):?>
    <tr>
        <td align="right" valign="top"><font class="tablebodytext"><b><?=GetMessage("FORM_USER")?></b></font></td>
        <td valign="top" nowrap><font class="tablebodytext"><?
            if (intval($arrResult["USER_ID"])>0) :
                echo "<font class='tablebodytext'>[</font><a class='tablebodylink' title='".GetMessage("FORM_EDIT_USER")."' href='user_edit.php?lang=".lang."&id=".$arrresult["user_id"]."'>".$arrresult["user_id"]."</a><font class='tablebodytext'>] (".htmlspecialchars($arrResult["LOGIN"]).") ".htmlspecialchars($arrResult["USER_NAME"])."</font>";
                echo ($arrResult["USER_AUTH"]=="N") ? " <font class='filteroff'>".GetMessage("FORM_NOT_AUTH")."</font>" : "";
            else :
                echo "<font class='tablebodytext'>".GetMessage("FORM_NOT_REGISTERED")."</font>";
            endif;
            ?></font></td>
    </tr>
    <?if (CModule::IncludeModule("statistic")):?>
    <tr>
        <td align="right" valign="top"><font class="tablebodytext"><b><?=GetMessage("FORM_GUEST")?></b></font></td>
        <td valign="top"><font class="tablebodytext">[<a title="<?=GetMessage("FORM_GUEST_ALT")?>" class="tablebodylink" href="/bitrix/admin/guest_list.php?lang=<?=lang?>&find_id=<?=$arrresult["stat_guest_id"]?>&set_filter=y"><?=$arrresult["stat_guest_id"]?></a>]</font></td>
    </tr>
    <tr>
        <td align="right" valign="top"><font class="tablebodytext"><b><?=GetMessage("FORM_SESSION")?></b></font></td>
        <td valign="top"><font class="tablebodytext">[<a title="<?=GetMessage("FORM_SESSION_ALT")?>" class="tablebodylink" href="/bitrix/admin/session_list.php?lang=<?=lang?>&find_id=<?=$arrresult["stat_session_id"]?>&set_filter=y"><?=$arrresult["stat_session_id"]?></a>]</font></td>
    </tr>
    <?endif;?>
    <?endif;?>
</table>
<br>
<?
    /*
    Y - show the required form fields in both filter and table; 
    N - hide form fields
    */
    $SHOW_ADDITIONAL = "N"; 

    /*
    Y - show values of ANSWER_VALUE in round brackets
    N - do not show values of ANSWER_VALUE
    */
    $SHOW_ANSWER_VALUE = "N";

    CForm::ShowResult($RESULT_ID, $VIEW_TEMPLATE, "show", $SHOW_ADDITIONAL, $SHOW_ANSWER_VALUE); 

else : 
    echo ShowError("Form not found");
endif;
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog.php"); 
?>