Documentation

GetResultAnswerArray

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

The method returns arrays containing information on the web form [link=90284#question]questions[/link], and both [link=90284#field]fields[/link] and [link=90284#answer]answers to questions[/link]. Non-static method.

Method parameters

Parameter Description Available from version
form_id Web form ID. Deleted from 3.3.10
columns Parameter passes the array, describing the web form questions and fields that are:
  1. active;
  2. included in the results table.
This array keys are question/fields IDs; values - an array, describing the question/field itself, which, in turn has the following keys:
  • ID - question/field ID;
  • FORM_ID - Web form ID;
  • TIMESTAMP_X - question/field modification date;
  • ACTIVE - active status flag [Y|N];
  • TITLE - question text, or field title;
  • TITLE_TYPE - text type;
  • SID - question/field symbol ID;
  • C_SORT - sorting order;
  • ADDITIONAL - if set to Y this record is a question; if set to N - the web form field;
  • REQUIRED - specifies if the answer to question is required [Y|N];
  • IN_FILTER - specifies, if question/field is shown in the filter of web form results [Y|N];
  • IN_RESULTS_TABLE - specifies if question/field is shown in the results table [Y|N];
  • IN_EXCEL_TABLE - specifies, if question/field is shown in the Excel table with results [Y|N];
  • FIELD_TYPE field type, the following values are possible:
    • text - text;
    • integer - number;
    • date - date.
  • IMAGE_ID - image ID in the question description;
  • COMMENTS - comment;
  • FILTER_TITLE - title for filter field for this question/field;
  • RESULTS_TABLE_TITLE - results table column title.
Example:
Array
(
    [140] => Array
        (
            [ID] => 140
            [FORM_ID] => 4
            [TIMESTAMP_X] => 19.05.2005 11:42:04
            [ACTIVE] => Y
            [TITLE] => Full name
            [TITLE_TYPE] => html
            [SID] => VS_NAME
            [C_SORT] => 100
            [ADDITIONAL] => N
            [REQUIRED] => Y
            [IN_FILTER] => Y
            [IN_RESULTS_TABLE] => N
            [IN_EXCEL_TABLE] => N
            [FIELD_TYPE] => 
            [IMAGE_ID] => 
            [COMMENTS] => 
            [FILTER_TITLE] => 
            [RESULTS_TABLE_TITLE] => 
        )

    [144] => Array
        (
            [ID] => 144
            [FORM_ID] => 4
            [TIMESTAMP_X] => 11.11.2004 18:11:21
            [ACTIVE] => Y
            [TITLE] => Areas of interest?
            [TITLE_TYPE] => text
            [SID] => VS_INTEREST
            [C_SORT] => 500
            [ADDITIONAL] => N
            [REQUIRED] => N
            [IN_FILTER] => Y
            [IN_RESULTS_TABLE] => Y
            [IN_EXCEL_TABLE] => Y
            [FIELD_TYPE] => 
            [IMAGE_ID] => 
            [COMMENTS] => 
            [FILTER_TITLE] => 
            [RESULTS_TABLE_TITLE] => 
        )
    ...
)
answers Contains array with answers to questions of the web from, as well as web form values. Keys to this array are:
  • RESULT_ID - result ID;
  • FIELD_ID - question/field ID;
  • SID - question/field symbol ID;
  • TITLE - question text or the web form field title;
  • TITLE_TYPE - question text type. The following values are possible:
    • text - text;
    • html - HTML code.
  • FILTER_TITLE - title of filter field for this question/field;
  • RESULTS_TABLE_TITLE - column title for results table;
  • ANSWER_ID - answer ID;
  • ANSWER_TEXT - answer parameter ANSWER_TEXT, recorded into the result table;
  • MESSAGE - answer parameter ANSWER_TEXT, stored in the answer table (synonym of the key ANSWER_TEXT);
  • ANSWER_VALUE - answer parameter ANSWER_VALUE, recorded in results table;
  • VALUE - answer parameter ANSWER_VALUE, stored in the results table (synonym of the key ANSWER_VALUE);
  • USER_TEXT - text, inputted by user ;
  • USER_DATE - date, inputted by user (this key can contain the value, only if FIELD_TYPE="date");
  • USER_FILE_ID - ID of the file, uploaded by user (this key can contain the value, only if FIELD_TYPE="image" or FIELD_TYPE="file");
  • USER_FILE_NAME - original name of downloaded file (this key will contain the value, only if FIELD_TYPE="image" or FIELD_TYPE="file");
  • USER_FILE_IS_IMAGE - "Y" - if FIELD_TYPE="image", "N" - if FIELD_TYPE="file"
  • USER_FILE_HASH - unique hash, used when showing the file (this key can contain the value, only if FIELD_TYPE="file");
  • USER_FILE_SUFFIX - suffix to the downloaded user file (this key can contain the value, only if FIELD_TYPE="file");
  • USER_FILE_SIZE - file size in bytes (this key can contain the value, only if FIELD_TYPE="image" or FIELD_TYPE="file");
  • FIELD_TYPE - answer field type. The following values are possible:
    • text - single line text field;
    • textarea - multiline text field;
    • radio - radio button;
    • checkbox - multiple selection checkbox;
    • dropdown - dropdown list of single selection element;
    • multiselect - multiple selection list element;
    • date - field for date input in the calendar;
    • image - field for image input;
    • file - field for custom file input;
    • password - single line field for password input.
  • FIELD_WIDTH - answer field width;
  • FIELD_HEIGHT - answer field height;
  • FIELD_PARAM - answer field parameters.
Example:
Array
(
    [186] => Array
        (
            [140] => Array
                (
                    [586] => Array
                        (
                            [RESULT_ID] => 186
                            [FIELD_ID] => 140
                            [SID] => VS_NAME
                            [TITLE] => Full name
                            [TITLE_TYPE] => html
                            [FILTER_TITLE] => 
                            [RESULTS_TABLE_TITLE] => 
                            [ANSWER_ID] => 586
                            [ANSWER_TEXT] =>  
                            [MESSAGE] =>  
                            [ANSWER_VALUE] => 
                            [VALUE] => 
                            [USER_TEXT] => John Smith
                            [USER_DATE] => 
                            [USER_FILE_ID] => 
                            [USER_FILE_NAME] => 
                            [USER_FILE_IS_IMAGE] => 
                            [USER_FILE_HASH] => 
                            [USER_FILE_SUFFIX] => 
                            [USER_FILE_SIZE] => 
                            [FIELD_TYPE] => text
                            [FIELD_WIDTH] => 50
                            [FIELD_HEIGHT] => 0
                            [FIELD_PARAM] => 
                        )
                )

            [144] => Array
                (
                    [594] => Array
                        (
                            [RESULT_ID] => 186
                            [FIELD_ID] => 144
                            [SID] => VS_INTEREST
                            [TITLE] => Areas of interest?
                            [TITLE_TYPE] => text
                            [FILTER_TITLE] => 
                            [RESULTS_TABLE_TITLE] => 
                            [ANSWER_ID] => 594
                            [ANSWER_TEXT] => foreign languages
                            [MESSAGE] => foreign languages
                            [ANSWER_VALUE] => 4
                            [VALUE] => 4
                            [USER_TEXT] => 
                            [USER_DATE] => 
                            [USER_FILE_ID] => 
                            [USER_FILE_NAME] => 
                            [USER_FILE_IS_IMAGE] => 
                            [USER_FILE_HASH] => 
                            [USER_FILE_SUFFIX] => 
                            [USER_FILE_SIZE] => 
                            [FIELD_TYPE] => checkbox
                            [FIELD_WIDTH] => 0
                            [FIELD_HEIGHT] => 0
                            [FIELD_PARAM] => 
                        )

                    [595] => Array
                        (
                            [RESULT_ID] => 186
                            [FIELD_ID] => 144
                            [SID] => VS_INTEREST
                            [TITLE] => Areas of interest?
                            [TITLE_TYPE] => text
                            [FILTER_TITLE] => 
                            [RESULTS_TABLE_TITLE] => 
                            [ANSWER_ID] => 595
                            [ANSWER_TEXT] => programming
                            [MESSAGE] => programming
                            [ANSWER_VALUE] => 5
                            [VALUE] => 5
                            [USER_TEXT] => 
                            [USER_DATE] => 
                            [USER_FILE_ID] => 
                            [USER_FILE_NAME] => 
                            [USER_FILE_IS_IMAGE] => 
                            [USER_FILE_HASH] => 
                            [USER_FILE_SUFFIX] => 
                            [USER_FILE_SIZE] => 
                            [FIELD_TYPE] => checkbox
                            [FIELD_WIDTH] => 0
                            [FIELD_HEIGHT] => 0
                            [FIELD_PARAM] => SELECTED class=inputcheckbox
                        )
                )
            ...
        )
    ...
)
answers2 Parameter contains references to the array, which basically is the same as the 'answers' array, but has slightly different structure.

Example:
Array
(
    [186] => Array
        (
            [VS_NAME] => Array
                (
                    [0] => Array
                        (
                            [RESULT_ID] => 186
                            [FIELD_ID] => 140
                            [SID] => VS_NAME
                            [TITLE] => Full name
                            [TITLE_TYPE] => html
                            [FILTER_TITLE] => 
                            [RESULTS_TABLE_TITLE] => 
                            [ANSWER_ID] => 586
                            [ANSWER_TEXT] => 
                            [MESSAGE] =>  
                            [ANSWER_VALUE] => 
                            [VALUE] => 
                            [USER_TEXT] => John Smith
                            [USER_DATE] => 
                            [USER_FILE_ID] => 
                            [USER_FILE_NAME] => 
                            [USER_FILE_IS_IMAGE] => 
                            [USER_FILE_HASH] => 
                            [USER_FILE_SUFFIX] => 
                            [USER_FILE_SIZE] => 
                            [FIELD_TYPE] => text
                            [FIELD_WIDTH] => 50
                            [FIELD_HEIGHT] => 0
                            [FIELD_PARAM] => 
                        )

                )


           [VS_INTEREST] => Array
                (
                    [0] => Array
                        (
                            [RESULT_ID] => 186
                            [FIELD_ID] => 144
                            [SID] => VS_INTEREST
                            [TITLE] => Areas of interest?
                            [TITLE_TYPE] => text
                            [FILTER_TITLE] => 
                            [RESULTS_TABLE_TITLE] => 
                            [ANSWER_ID] => 594
                            [ANSWER_TEXT] => foreign languages
                            [MESSAGE] => foreign languages
                            [ANSWER_VALUE] => 4
                            [VALUE] => 4
                            [USER_TEXT] => 
                            [USER_DATE] => 
                            [USER_FILE_ID] => 
                            [USER_FILE_NAME] => 
                            [USER_FILE_IS_IMAGE] => 
                            [USER_FILE_HASH] => 
                            [USER_FILE_SUFFIX] => 
                            [USER_FILE_SIZE] => 
                            [FIELD_TYPE] => checkbox
                            [FIELD_WIDTH] => 0
                            [FIELD_HEIGHT] => 0
                            [FIELD_PARAM] => 
                        )

                    [1] => Array
                        (
                            [RESULT_ID] => 186
                            [FIELD_ID] => 144
                            [SID] => VS_INTEREST
                            [TITLE] => Areas of interest?
                            [TITLE_TYPE] => text
                            [FILTER_TITLE] => 
                            [RESULTS_TABLE_TITLE] => 
                            [ANSWER_ID] => 595
                            [ANSWER_TEXT] => programming
                            [MESSAGE] => programming
                            [ANSWER_VALUE] => 5
                            [VALUE] => 5
                            [USER_TEXT] => 
                            [USER_DATE] => 
                            [USER_FILE_ID] => 
                            [USER_FILE_NAME] => 
                            [USER_FILE_IS_IMAGE] => 
                            [USER_FILE_HASH] => 
                            [USER_FILE_SUFFIX] => 
                            [USER_FILE_SIZE] => 
                            [FIELD_TYPE] => checkbox
                            [FIELD_WIDTH] => 0
                            [FIELD_HEIGHT] => 0
                            [FIELD_PARAM] => SELECTED class=inputcheckbox
                        )
                )
            ...
        )
    ...
)
filter

Array to filter selected values. Optional parameter. The following array keys are possible:
  • RESULT_ID* - ID of the result (exact match will be searched by default);
  • RESULT_ID_EXACT_MATCH - if the value is "N", instances will be searched when filtering by RESULT_ID;
  • FIELD_ID* - ID of question/field (exact match will be searched by default);
  • FIELD_ID_EXACT_MATCH - if the value is "N", instances will be searched when filtering by FIELD_ID;
  • FIELD_SID* - symbol code of question/field (an instance will be searched by default);
  • FIELD_SID_EXACT_MATCH - if the value is "Y", the exact match ill be searched hen filtering by FIELD_SID;
  • IN_RESULTS_TABLE - if the value is "Y", the answers to question (or web form field values) will be shown in the results table;
  • IN_EXCEL_TABLE - if the value is "Y", the answers to question (or web form field values) will be shown in the result Excel table.
* - complex logic is permitted.
arrAnswersVarname 3.3.10. Deleted from version 4.0.4
web_form_id Web form ID. 3.3.10
arrAnswersSID 4.0.4

See Also

  • [link=90369]CFormResult::GetDataByID[/link]
  • [link=90333]CFormField::GetList[/link]
  • [link=90326]CFormAnswer::GetList[/link]

Examples of use

// get data by the result ID=145
CForm::GetResultAnswerArray($FORM_ID, 
	$arrColumns, 
	$arrAnswers, 
	$arrAnswersVarname, 
	array("RESULT_ID" => "145"));

echo "<pre>";
echo "arrColumns:";
print_r($arrColumns);
echo "arrAnswers:";
print_r($arrAnswers);
echo "arrAnswersVarname:";
print_r($arrAnswersVarname);
echo "</pre>";


© «Bitrix24», 2001-2024
Up