Documentation

GetPasswordField

string
CForm::GetPasswordField(
 int answer_id,
 string value = "",
 mixed size = "",
 string add_to_text = "class=\"inputtext\""
)

Returns HTML code for single line text field. This field is intended for "password" type [link=90284#answer]answer[/link] input. Non-static method.

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

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

Method parameters

Parameter Description
answer_id ID of [link=90284#answer]answer[/link].
value The value of resulting text field:
<input type="password" value="value" ...>

Optional parameter. Empty by default.
size Width of resulting text field:
<input type="password" size="size" ...>

Optional parameter. Empty by default.
add_to_text Custom HTML o be added to the resulting text field HTML tag:
<input type="password" add_to_text ...>

Optional parameter. By default - "class=\"inputtext\"".

See Also

  • [link=90308]CForm::GetPasswordValue[/link]
  • [link=90281]HTML field names[/link]

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

            // array describing the field for password input 
            // стефшты minimally-required fields
            $arAnswer = array(
                "ID"            => 609,   // ID of the field for answer to the question "Password"
                "FIELD_WIDTH"   => 10,    // field width
                "FIELD_PARAM"   => ""     // field parameters
                );

            // get current value
            $value = CForm::GetPasswordValue($arAnswer["ID"], $arAnswer, $arrVALUES);

            // display the field
            echo CForm::GetPasswordField(
                $arAnswer["ID"],
                $value,
                $arAnswer["FIELD_WIDTH"],
                $arAnswer["FIELD_PARAM"]
                );
            ?></td>
    </tr>
</table>
<input type="submit" name="save" value="Save">
</form>


© «Bitrix24», 2001-2024
Up