GetDataByID
CForm::GetDataByID( int FORM_ID, array &arForm, array &arQuestions, array &arAnswers, array &arDropDown, array &arMultiSelect, char(1) additional="Y" );
The function returns arrays describing the form.
Parameters
FORM_ID | Form ID. |
arForm | Array containing the form parameters with keys:
SampleArray ( [ID] => 4 [TIMESTAMP_X] => 17.09.2003 12:43:46 [NAME] => Visitor review [VARNAME] => FORM [BUTTON] => Save [C_SORT] => 300 [LID] => ru [IMAGE_ID] => 717 [DESCRIPTION] => Used to collect info on visitors. [DESCRIPTION_TYPE] => text [SHOW_TEMPLATE] => default.php [MAIL_EVENT_TYPE] => FORM_FILLING_FORM [MAIL_TEMPLATE] => 262 [SHOW_RESULT_TEMPLATE] => default.php [PRINT_RESULT_TEMPLATE] => default.php [EDIT_RESULT_TEMPLATE] => default.php [STAT_EVENT1] => form [STAT_EVENT2] => form [STAT_EVENT3] => [C_FIELDS] => 1 [QUESTIONS] => 9 ) |
arQuestions | Array with questions and fields of the form. Each key in the array is a
question or field identifier. Each value is an array describing a single
question or field. Such array have the following keys.
SampleArray ( [VS_NAME] => Array ( [ID] => 140 [FORM_ID] => 4 [TIMESTAMP_X] => 28.08.2003 11:45:57 [ACTIVE] => Y [TITLE] => First and last name [TITLE_TYPE] => html [VARNAME] => VS_NAME [C_SORT] => 100 [ADDITIONAL] => N [REQUIRED] => Y [IN_FILTER] => Y [IN_RESULTS_TABLE] => Y [FIELD_TYPE] => [IMAGE_ID] => [COMMENTS] => ) [VS_BIRTHDAY] => Array ( [ID] => 141 [FORM_ID] => 4 [TIMESTAMP_X] => 16.09.2003 17:27:16 [ACTIVE] => Y [TITLE] => Date of birth [TITLE_TYPE] => text [VARNAME] => VS_BIRTHDAY [C_SORT] => 200 [ADDITIONAL] => N [REQUIRED] => Y [IN_FILTER] => Y [IN_RESULTS_TABLE] => Y [FIELD_TYPE] => [IMAGE_ID] => [COMMENTS] => ) ... ) |
arAnswers | Array with answers to questions of the form. Each key in the array is a
question identifier. Each value is an array describing answers for a single
question . Such array have the following keys.
SampleArray ( [VS_NAME] => Array ( [0] => Array ( [ID] => 586 [FIELD_ID] => 140 [TIMESTAMP_X] => 2003-08-28 11:45:57 [MESSAGE] => [C_SORT] => 100 [ACTIVE] => Y [VALUE] => [FIELD_TYPE] => text [FIELD_WIDTH] => 50 [FIELD_HEIGHT] => 0 [FIELD_PARAM] => ) ) [VS_MARRIED] => Array ( [0] => Array ( [ID] => 589 [FIELD_ID] => 143 [TIMESTAMP_X] => 2003-08-28 14:51:29 [MESSAGE] => yes [C_SORT] => 100 [ACTIVE] => Y [VALUE] => [FIELD_TYPE] => radio [FIELD_WIDTH] => 0 [FIELD_HEIGHT] => 0 [FIELD_PARAM] => ) [1] => Array ( [ID] => 590 [FIELD_ID] => 143 [TIMESTAMP_X] => 2003-08-28 14:51:29 [MESSAGE] => no [C_SORT] => 200 [ACTIVE] => Y [VALUE] => [FIELD_TYPE] => radio [FIELD_WIDTH] => 0 [FIELD_HEIGHT] => 0 [FIELD_PARAM] => ) ) ... ) |
arDropDown | Array containing the suggested answers for fields of the type dropdown.SampleArray ( [VS_AGE] => Array ( [reference] => Array ( [0] => - [1] => 10-19 [2] => 20-29 [3] => 30-39 [4] => 40-49 [5] => 50-59 [6] => over 60 ) [reference_id] => Array ( [0] => 608 [1] => 596 [2] => 597 [3] => 598 [4] => 599 [5] => 600 [6] => 601 ) [param] => Array ( [0] => NOT_ANSWER [1] => [2] => SELECTED [3] => [4] => [5] => [6] => ) ) ) |
arMultiSelect | Array containing the suggested answers for fields of the type multiselect.
ПримерArray ( [VS_EDUCATION] => Array ( [reference] => Array ( [0] => school [1] => college [2] => post-graduate course ) [reference_id] => Array ( [0] => 602 [1] => 603 [2] => 604 ) [param] => Array ( [0] => [1] => SELECTED [2] => ) ) ) | additional | If set to "Y", the method returns form fields as well as questions in the array arQuestions. If "N" (default), questions only are returned. |
Example
<? /* Returns the HTML code of the form with respect to the user permissions WEB_FORM_VARNAME - form identifier VARS - array of values for the form fields SHOW_TEMPLATE - form template PREVIEW - set to "Y" to disable the button "Save" */ function Show($WEB_FORM_VARNAME, $arrVALUES=false, $SHOW_TEMPLATE=false, $PREVIEW="N") { $err_mess = (CAllForm::err_mess())."<".br>Function: Show<".br>Line: "; global $DB, $MESS, $APPLICATION, $USER, $HTTP_POST_VARS, $HTTP_GET_VARS; $z = CForm::GetBySID($WEB_FORM_VARNAME); $zr = $z->Fetch(); $WEB_FORM_ID = intval($zr["ID"]); $WEB_FORM_ID = CForm::GetDataByID($WEB_FORM_ID, $arForm, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect); if (intval($WEB_FORM_ID)>0) { $F_RIGHT = CAllForm::GetPermission($WEB_FORM_ID); if (intval($F_RIGHT)>=10) { if ($SHOW_TEMPLATE!==false) $template = $SHOW_TEMPLATE; else { if (strlen($arForm["SHOW_TEMPLATE"])<=0) $template = "default.php"; else $template = $arForm["SHOW_TEMPLATE"]; } require_once ($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/form/include.php"); $path = COption::GetOptionString("form","SHOW_TEMPLATE_PATH"); include (GetLangFileName($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/form/lang/", "/include.php")); include(GetLangFileName($_SERVER["DOCUMENT_ROOT"].$path."lang/", "/".$template)); include($_SERVER["DOCUMENT_ROOT"].$path.$template); } } } ?>
© «Bitrix24», 2001-2024