GetCheckBoxValue
int CForm::GetCheckBoxValue( string question_sid, array answer, mixed form_values = false )
If the array, passed in the parameter form_values, is initialized (for example, when editing the result), the method returns ID of answer (
If the array, passed in the parameter form_values, is not initialized (for example, when creating new result), the method will return the default value for this answer (
Non-static method.
Method parameters
Parameter | Description |
---|---|
question_sid | Symbolic identifier of [link= 6660053#question]question[/link]. |
answer | Array, describing parameters of [link= 6660053#answer]answer[/link], with required keys:
|
form_values | Associative array of values, received from web form when crating new or editing an existing [link= 6660053#result]result[/link] (standard array $_REQUEST). This array can also be received via the method CFormResult::GetDataByIDForHTML. Optional parameter. False by default. |
See Also
Examples of use
<? /******************************************* Result edit *******************************************/ $RESULT_ID = 12; // result ID // if the "Save" is clicked... if (strlen($_REQUEST["save"])>0) { // use data, received from the web form $arrVALUES = $_REQUEST; } else { // generate the array from the result data $arrVALUES = CFormResult::GetDataByIDForHTML($RESULT_ID); } ?> <form action="" method="POST"> <table> <tr> <td>What are your areas of interest?</td> <td><? /********************************************************** display two checkboxes (math/physics) as options to answer the question "What are your areas of interest?" **********************************************************/ $QUESTION_SID = "INTEREST"; // question ID /*********************** checkbox "math" ***********************/ // array describing one checkbox // contains minimally-required fields $arAnswer = array( "ID" => 591, // checkbox ID "FIELD_PARAM" => "checked class=\"inputcheckbox\"" // answer parameter ); // get current value $value = CForm::GetCheckBoxValue($QUESTION_SID, $arAnswer, $arrVALUES); // display the checkbox echo CForm::GetCheckBoxField( $QUESTION_SID, $arAnswer["ID"], $value, $arAnswer["FIELD_PARAM"] ); echo "math<br>"; /*********************** checkbox "physics" ***********************/ // array describing one checkbox // contains minimally-required fields $arAnswer = array( "ID" => 593, // checkbox ID "FIELD_PARAM" => "" // answer parameter ); // get current value $value = CForm::GetCheckBoxValue($QUESTION_SID, $arAnswer, $arrVALUES); // display the checkbox echo CForm::GetCheckBoxField( $QUESTION_SID, $arAnswer["ID"], $value, $arAnswer["FIELD_PARAM"] ); echo "physics"; ?></td> </tr> </table> <input type="submit" name="save" value="Save"> </form>
© «Bitrix24», 2001-2024