Set
mixed CFormAnswer::Set( array fields, mixed answer_id = false, mixed current_question_id = false )
The method Set adds a new answer or modifies the existing one. Returns the ID of the modified or added answer on success, or false otherwise.
Parameters
fields | Array of value which accept the following keys:
|
answer_id | The ID of the modified answer. Optional parameter. False by default which means a new answer is to be added. |
current_question_id | The ID of the answer to which the modified answer is bound. If specified, this parameter will speed up the method execution. Optional parameter. False by default. |
See Also
Example
<? $QUESTION_ID = 140; // The ID of the question "First and last names" $arFields = array( "QUESTION_ID" => $QUESTION_ID, "MESSAGE" => " ", "C_SORT" => 100, "ACTIVE" => "Y", "FIELD_TYPE" => "text", "FIELD_WIDTH" => "40" ); $NEW_ID = CFormAnswer::Set($arFields); if ($NEW_ID>0) echo "The ID=".$NEW_ID." has been successfully added"; else // error { // display the error description global $strError; echo $strError; } ?>
<? $QUESTION_ID = 143; // The ID of the question "Are you married?" $arFields = array( "QUESTION_ID" => $QUESTION_ID, "MESSAGE" => "yes", "C_SORT" => 100, "ACTIVE" => "Y", "FIELD_TYPE" => "radio", "FIELD_PARAM" => "checked" ); CFormAnswer::Set($arFields); $arFields = array( "QUESTION_ID" => $QUESTION_ID, "MESSAGE" => "no", "C_SORT" => 200, "ACTIVE" => "Y", "FIELD_TYPE" => "radio" ); CFormAnswer::Set($arFields); ?>
© «Bitrix24», 2001-2024