Documentation

GetPasswordValue

string
CForm::GetPasswordValue(
 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 current value of the [link= 6660053#answer]answer[/link] of "password" type, 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 a new [link= 6660053#result]result[/link]), the method returns the default value for this [link= 6660053#answer]answer[/link] (i. e. what is specified in the answer["VALUE"]).

Not-static method.

Method parameters

Parameter Description
answer_id ID of [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 answer. Generally, this default value becomes the parameter ANSWER_VALUE of the answer.
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" was 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
            // contains minimally-requried 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 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