SetField
CFormResult::SetField( int result_id, string field_sid, mixed value = false )
The function updates the values of the answer to the question for the specified result or updates the value of the field. Non-static method.
Method parameters
Parameter | Description | Available from version |
---|---|---|
result_id | ID of the result. | |
field_varname | Deleted from version 4.0.4 | |
field_sid | Symbol ID of the question or field. | 4.0.4 |
value | Value to be saved. Depending on the type of the updated field, this parameter has different format.
|
See Also
Examples of use
$RESULT_ID = 186; /************************************************************** Updating answers to questions values **************************************************************/ // update answer to the question "Full name" $arVALUE = array(); $FIELD_SID = "VS_NAME"; // question symbol identifier $ANSWER_ID = 586; // answer field ID $arVALUE[$ANSWER_ID] = "John Smith"; CFormResult::SetField($RESULT_ID, $FIELD_SID, $arVALUE); // update answer to the question "Birthday" $arVALUE = array(); $FIELD_SID = "VS_BIRTHDAY"; // question symbol identifier $ANSWER_ID = 587; // answer field ID $arVALUE[$ANSWER_ID] = "18.06.1975"; CFormResult::SetField($RESULT_ID, $FIELD_SID, $arVALUE); // update answer to the question "Which areas of expertise you are interested in?" $arVALUE = array(); $FIELD_SID = "VS_INTEREST"; // question symbol identifier $arVALUE[612] = ""; // "mathematics" answer field ID $arVALUE[613] = ""; // "physics" answer field ID $arVALUE[614] = ""; // "history" answer field ID CFormResult::SetField($RESULT_ID, $FIELD_SID, $arVALUE); // update answer to the question "Photography" $arVALUE = array(); $FIELD_SID = "VS_PHOTO"; // question symbol identifier $ANSWER_ID = 607; // answer field ID $path = $_SERVER["DOCUMENT_ROOT"]."/images/news.gif"; // path to file $arVALUE[$ANSWER_ID] = CFile::MakeFileArray($path); CFormResult::SetField($RESULT_ID, $FIELD_SID, $arVALUE); // update answer to the question "CV" $arVALUE = array(); $FIELD_SID = "VS_RESUME"; // question symbol identifier $ANSWER_ID = 610; // answer field ID $path = $_SERVER["DOCUMENT_ROOT"]."/docs/alawarauthorarea.doc"; // path to file $arVALUE[$ANSWER_ID] = CFile::MakeFileArray($path); CFormResult::SetField($RESULT_ID, $FIELD_SID, $arVALUE); /************************************************************** Update the field values **************************************************************/ // update value of the field "Quote" $FIELD_SID = "VS_PRICE"; // question ID $VALUE = "155"; CFormResult::SetField($RESULT_ID, $FIELD_SID, $VALUE); ?>
© «Bitrix24», 2001-2024