Documentation

GetList

CDBResult
CFormField::GetList(
 int form_id,
 string get_only_fields,
 string &by = "s_sort",
 string &order = "asc",
 array filter = array(),
 bool &is_filtered
)

The method GetList returns a list of questions or fields of a web form as a CDBResult instance.

Parameters

Parameter Description
form_id The web form ID.
get_only_fields The following values are possible:
  • Y - the returned list should contain only the web form fields;
  • N - the returned list should contain only the web form questions;
  • ALL - the returned list can contain both questions and questions of a web form.
by Reference to the variable containing the field used to sort the result. The following values are possible: 
  • s_id - ID;
  • s_active - active state flag;
  • s_sid - the symbolic identifier;
  • s_sort - sort index;
  • s_title - the text of the question or the web form field title;
  • s_comments - administrative comments;
  • s_required - specifies the web form question must be answered;
  • s_in_results_table - specifies the question is to be included in the HTML table of results;
  • s_in_excel_table - specifies the question is to be included in the Excel table of results;
  • s_field_type - type of the web form field.
оrder Reference to the variable containing the sort order. The following values are possible:
  • asc - ascending;
  • desc - descending.
filter An array used to filter values. The following keys are possible:
  • ID* - the ID of the question or the field (by default the method accepts only the exact matches);
  • ID_EXACT_MATCH - if "N", the method performs loose searches (entry is sufficient) when filtering by ID;
  • SID* - the symbolic identifier of the question or the field (by default the method accepts only the exact matches);
  • SID_EXACT_MATCH - if "N", the method performs loose searches (entry is sufficient) when filtering by SID;
  • TITLE* - the text of the question or the web form field title (the method performs loose searches by default);
  • TITLE_EXACT_MATCH - set to "Y" for exact match searches when filtering by TITLE;
  • COMMENTS* - administrative comments (the method performs loose searches by default);
  • COMMENTS_EXACT_MATCH - set to "Y" for exact match searches when filtering by COMMENTS;
  • ACTIVE - active state flag [Y|N];
  • IN_RESULTS_TABLE - specifies the question is to be included in the HTML table of results [Y|N];
  • IN_EXCEL_TABLE - specifies the question is to be included in the Excel table of results [Y|N];
  • IN_FILTER - specifies the question is to be included in the filter [Y|N];
  • REQUIRED - specifies the web form question must be answered [Y|N].
* - /main/help/en/filter.php.html - complex logic allowed
is_filtered Reference to the variable containing true if the returned list is filtered, or false if the returned list is not filtered.

Example



<?
$FORM_ID = 4; // The ID of the web form

// form the filter array
$arFilter = Array(
    // question ID=140 or ID=141
  "ID"                    => "140 | 141",
    // we need the ID to match exactly
  "ID_EXACT_MATCH"        => "Y",
    // symbolic identifier
  "SID"                   => "VS_BIRTHDAY",
    // match symbolic identifier exactly
  "SID_EXACT_MATCH"       => "Y",
    // text of the question
  "TITLE"                 => "Birthday",
    // entry in text of the question is sufficient
  "TITLE_EXACT_MATCH"     => "N",
    // active state flag
  "ACTIVE"                => "Y",
    // we need questions which are in the HTML table of results
  "IN_RESULTS_TABLE"      => "Y",
    // we need questions which are in the Excel table of results
  "IN_EXCEL_TABLE"        => "N",
    // we need questions which are in the filter
  "IN_FILTER"             => "Y",
    // questions requiring an answer
  "REQUIRED"              => "Y",
);

// obtain the list of all questions of the web form #4
$rsQuestions = CFormField::GetList(
    $FORM_ID, 
    "N", 
    $by="s_id", 
    $order="desc", 
    $arFilter, 
    $is_filtered
    );
while ($arQuestion = $rsQuestions->Fetch())
{
    echo "<pre>"; print_r($arQuestion); echo "</pre>";
}
?>
© «Bitrix24», 2001-2024
Up