Bitrix Site Manager

CForm::GetResultAnswerArray

CForm::GetResultAnswerArray(
 int FORM_ID,
 array &arrColumns,
 array &arrAnswers,
 array &arrAnswersVarname=array(),
 array arFilter=array(),
);

The function returns arrays containing information on the form questions, fields and answers.

Parameters

ParameterDescription
FORM_ID Form ID.
arrColumns Array describing questions and fields of the form. This array contains only active questions and fields included in the results table. To get a full list of questions and fields, use the function CForm::GetFieldList.
arrAnswers Array containing answers to the questions and values of the fields of the form.
arrAnswersVarname Same as arrAnswers, but contains information in other form (see below).
arFilter Optional filter with the following possible keys:

Remarks

Sample array arrColumns:

Array
(
    [1] => Array
        (
            [ID] => 1
            [FORM_ID] => 2
            [TIMESTAMP_X] => 07.10.2003 14:34:14
            [ACTIVE] => Y
            [TITLE] => (T) - calculated insurance premium
            [TITLE_TYPE] => text
            [VARNAME] => CL_SUMMA
            [C_SORT] => 50
            [ADDITIONAL] => Y
            [REQUIRED] => N
            [IN_FILTER] => Y
            [IN_RESULTS_TABLE] => Y
            [FIELD_TYPE] => integer
            [IMAGE_ID] => 
            [COMMENTS] => 
            [FILTER_TITLE] => Cost:
            [RESULTS_TABLE_TITLE] => Cost
        )

    [9] => Array
        (
            [ID] => 9
            [FORM_ID] => 2
            [TIMESTAMP_X] => 13.10.2003 14:08:25
            [ACTIVE] => Y
            [TITLE] => Preferred area of application 
            [TITLE_TYPE] => text
            [VARNAME] => CL_CITY
            [C_SORT] => 200
            [ADDITIONAL] => N
            [REQUIRED] => Y
            [IN_FILTER] => Y
            [IN_RESULTS_TABLE] => Y
            [FIELD_TYPE] => 
            [IMAGE_ID] => 
            [COMMENTS] => 
            [FILTER_TITLE] => City:
            [RESULTS_TABLE_TITLE] => City
        )
	...
)

Sample array arrAnswers:

Array
(
    [307] => Array
        (
            [1] => Array
                (
                    [0] => Array
                        (
                            [RESULT_ID] => 307
                            [FIELD_ID] => 1
                            [ANSWER_ID] => 
                            [ANSWER_TEXT] => 
                            [ANSWER_VALUE] => 
                            [USER_TEXT] => 8910
                            [USER_FILE_ID] => 
                            [USER_FILE_NAME] => 
                            [USER_DATE] => 
                            [VARNAME] => CL_SUMMA
                            [TITLE] => (T) - calculated insurance premium
                            [TITLE_TYPE] => text
                            [FILTER_TITLE] => cost:
                            [RESULTS_TABLE_TITLE] => cost
                            [MESSAGE] => 
                            [VALUE] => 
                            [FIELD_TYPE] => 
                            [FIELD_WIDTH] => 
                            [FIELD_HEIGHT] => 
                            [FIELD_PARAM] => 
                        )

                )

            [9] => Array
                (
                    [1] => Array
                        (
                            [RESULT_ID] => 307
                            [FIELD_ID] => 9
                            [ANSWER_ID] => 1
                            [ANSWER_TEXT] => London
                            [ANSWER_VALUE] => 2/1.2
                            [USER_TEXT] => 
                            [USER_FILE_ID] => 
                            [USER_FILE_NAME] => 
                            [USER_DATE] => 
                            [VARNAME] => CL_CITY
                            [TITLE] => Preferred area of application 
                            [TITLE_TYPE] => text
                            [FILTER_TITLE] => City:
                            [RESULTS_TABLE_TITLE] => City
                            [MESSAGE] => London
                            [VALUE] => 2/1.2
                            [FIELD_TYPE] => dropdown
                            [FIELD_WIDTH] => 0
                            [FIELD_HEIGHT] => 0
                            [FIELD_PARAM] => 
                        )

                )
)

Sample array arrAnswersVarname:

Array
(
    [307] => Array
        (
            [CL_SUMMA] => Array
                (
                    [0] => Array
                        (
                            [RESULT_ID] => 307
                            [FIELD_ID] => 1
                            [ANSWER_ID] => 
                            [ANSWER_TEXT] => 
                            [ANSWER_VALUE] => 
                            [USER_TEXT] => 8910
                            [USER_FILE_ID] => 
                            [USER_FILE_NAME] => 
                            [USER_DATE] => 
                            [VARNAME] => CL_SUMMA
                            [TITLE] => (T) - calculated insurance premium
                            [TITLE_TYPE] => text
                            [FILTER_TITLE] => Cost:
                            [RESULTS_TABLE_TITLE] => Cost
                            [MESSAGE] => 
                            [VALUE] => 
                            [FIELD_TYPE] => 
                            [FIELD_WIDTH] => 
                            [FIELD_HEIGHT] => 
                            [FIELD_PARAM] => 
                        )

                )

            [CL_CITY] => Array
                (
                    [0] => Array
                        (
                            [RESULT_ID] => 307
                            [FIELD_ID] => 9
                            [ANSWER_ID] => 1
                            [ANSWER_TEXT] => London
                            [ANSWER_VALUE] => 2/1.2
                            [USER_TEXT] => 
                            [USER_FILE_ID] => 
                            [USER_FILE_NAME] => 
                            [USER_DATE] => 
                            [VARNAME] => CL_CITY
                            [TITLE] => Preferred area of application 
                            [TITLE_TYPE] => text
                            [FILTER_TITLE] => City:
                            [RESULTS_TABLE_TITLE] => City
                            [MESSAGE] => London
                            [VALUE] => 2/1.2
                            [FIELD_TYPE] => dropdown
                            [FIELD_WIDTH] => 0
                            [FIELD_HEIGHT] => 0
                            [FIELD_PARAM] => 
                        )

                )
        )
)

Example




CForm::GetResultAnswerArray($WEB_FORM_ID, $arrColumns, $arrAnswers, $arrAnswersVarname, array("IN_RESULTS_TABLE" => "Y"));
print_r($arrAnswers);
$colspan = 4;
reset($arrColumns);
while (list($key, $arrCol) = each($arrColumns)) :

	if (!is_array($arrNOT_SHOW_TABLE) || !in_array($arrCol["VARNAME"],$arrNOT_SHOW_TABLE)):

	if (($arrCol["ADDITIONAL"]=="Y" && $SHOW_ADDITIONAL=="Y") || $arrCol["ADDITIONAL"]!="Y") :
		$colspan++;
		if (strlen($arrCol["RESULTS_TABLE_TITLE"])<=0)
		{
			$title = ($arrCol["TITLE_TYPE"]=="html") ? strip_tags($arrCol["TITLE"]) : htmlspecialchars($arrCol["TITLE"]);
			$title = TruncateText($title,100);
		}
		else $title = htmlspecialchars($arrCol["RESULTS_TABLE_TITLE"]);
		?>
		<td valign="top" class="tablehead"><font class="tableheadtext"><?
		if ($F_RIGHT>=25) :
		?>[<a title="<?=GetMessage("FORM_FIELD_PARAMS")?>" class="tablebodylink" href="/bitrix/admin/form_field_edit.php?lang=<?=lang?>&id=<?=$arrcol["id"]?>&web_form_id=<?=$web_form_id?>&additional=<?=$arrcol["additional"]?>"><?=$arrcol["id"]?></a>]<br><?
		endif;
		echo $title;
		?></td><?
	endif;
	endif;
endwhile;