Documentation

GetTextAreaField

string
CForm::GetTextAreaField(
 int answer_id,
 int cols = "",
 int rows = "",
 string add_to_textarea = "class=\"inputtextarea\""
 string value = "",
)

The method returns HTML code of multi-line text field. This field is intended for input of the "textarea" [link=90284#answer]answer[/link] type.

This method can be used in both the web form for creation of new [link=90284#result]result[/link], and in the form of editing the existing result. Non-static method.

Note
Name of resulting HTML field will be generated by the following mask:
form_textareaanswer_id

Method parameters

Parameter Description
answer_id ID of [link=90284#answer]answer[/link].
cols Width of resulting multi-line text field:
<textarea cols="cols" ...>

Optional parameter. Empty by default.
rows Height of resulting multi-line text field:
<textarea rows="rows" ...>

Optional parameter. Empty by default.
add_to_textarea Custom HTML that will be added to the resulting tag of multi-line text field:
<textarea add_to_textarea ...>

Optional parameter. By default - "class=\"inputtextarea\"".
value Value of resulting multi-line text field:
<textarea ...>value</textarea>

Optional parameter. Empty by default.

See Also

  • [link=90314]CForm::GetTextAreaValue[/link]
  • [link=90281]HTML field names[/link]

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>Address:</td>
        <td><?

            // array, describing the single line text field 
            // contains minimally-required fields
            $arAnswer = array(
                "ID"            => 588,   // ID of the field for answer to the question "Your address?"
                "VALUE"         => "",    // parameter ANSWER_VALUE (значение по умолчанию)
                "FIELD_WIDTH"   => 10,    // field width
                "FIELD_HEIGHT"  => 5,     // field height
                "FIELD_PARAM"   => ""     // field parameters
                );

            // get the 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