GetTextAreaValue
string CForm::GetTextAreaValue( int answer_id, array answer, mixed form_values = false )
If the array, passed in the parameter form_values, is initialized (for example, when editing the [link= 6660053#result]result[/link]), the method returns the current value of the "textarea" type [link= 6660053#answer]answer[/link], ID of which is passed in the parameter answer_id.
If the array, passed in the parameter form_values, is not initialized (for example, when creating new [link= 6660053#result]result[/link]), the method will return the default value for this [link= 6660053#answer]answer[/link] (that is, what is set in the
Non-static method.
Method parameters
Parameter | Description |
---|---|
answer_id | ID of the [link= 6660053#answer]answer[/link]. |
answer | Array, describing the parameters of the [link= 6660053#answer]answer[/link], with required VALUE key and with the default value for the [link= 6660053#answer]answer[/link]. Generally, this default value becomes the parameter ANSWER_VALUE of the [link= 6660053#answer] answer[/link]. |
form_values | Associative array of values, received via web form when creating new or editing existing [link= 6660053#result]result[/link] (standard array $_REQUEST). This array can be also received by 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>Address:</td> <td><? // array describing multi-line text field // contains minimally-requried fields $arAnswer = array( "ID" => 588, // ID of the field for answer to the question "Your address?" "VALUE" => "", // parameter ANSWER_VALUE (default value) "FIELD_WIDTH" => 10, // field width "FIELD_HEIGHT" => 5, // field height "FIELD_PARAM" => "" // field parameters ); // get current value $value = CForm::GetTextAreaValue($arAnswer["ID"], $arAnswer, $arrVALUES); // display the field echo CForm::GetTextAreaField( $arAnswer["ID"], $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_HEIGHT"], $arAnswer["FIELD_PARAM"], $value ); ?></td> </tr> </table> <input type="submit" name="save" value="Save"> </form>
© «Bitrix24», 2001-2024