GetTextField
string CForm::GetTextField( int answer_id, string value = "", mixed size = "", string add_to_text = "class=\"inputtext\"" )
The method returns HTML code of single line text field. This field is designed to input a the "text" type answer.
The method can be used both in the web form to create new result, and to edit the existing one. Non-static method.
Note
Name of resulting HTML field will be generated based on the following mask:
form_text_answer_id
Method parameters
Parameter | Description |
---|---|
answer_id | ID of the answer. |
value | resulting text field value:
<input type="text" value="value" ...> Optional parameter. Empty by default. |
size | Width of the resulting text field:
<input type="text" size="size" ...> Optional parameter. Empty by default. |
add_to_text | Custom HTML to be added to the resulting text field HTML tag:
<input type="text" add_to_text ...> Optional parameter. Default value is "class=\"inputtext\"". |
See Also
Examples of use
<? /******************************************* Result edit *******************************************/ $RESULT_ID = 12; // Result ID // if "Save" button is clicked... if (strlen($_REQUEST["save"])>0) { // use the data received from the form $arrVALUES = $_REQUEST; } else { // generate this array from the data by the result $arrVALUES = CFormResult::GetDataByIDForHTML($RESULT_ID); } ?> <form action="" method="POST"> <table> <tr> <td>Last name:</td> <td><? // array, describing the single line text field // contains minimally-required fields $arAnswer = array( "ID" => 586, // ID of the field for answer to the question "Your last name?" "VALUE" => "", // parameter ANSWER_VALUE (default value) "FIELD_WIDTH" => 10, // field width "FIELD_PARAM" => "" // field parameters ); // get the current value $value = CForm::GetTextValue($arAnswer["ID"], $arAnswer, $arrVALUES); // display the field echo CForm::GetTextField( $arAnswer["ID"], $value, $arAnswer["FIELD_WIDTH"], $arAnswer["FIELD_PARAM"] ); ?></td> </tr> </table> <input type="submit" name="save" value="Save"> </form>
© «Bitrix24», 2001-2024