Documentation

Check

mixed
CForm::Check(
 int form_id,
 array values = false,
 int result_id = false,
 string check_rights = "Y",
 string return_array = "N"
)

The method checks the form required fields, date and time format and the file type for validity. Current user access permissions are checked if required. On failure - returns error description. Non-static method.

Method parameters

Parameter Description Available from version
form_id ID of the [link= 6660053#form]Web form[/link].
values Array of web form input values.
Optional parameter. False by default (use standard array $_REQUEST).

Example:
Array
(
    [form_text_586] => John Smith 
    [form_date_587] => 10.03.1992
    [form_textarea_588] => г. New York
    [form_radio_VS_MARRIED] => 589
    [form_checkbox_VS_INTEREST] => Array
        (
            [0] => 592
            [1] => 593
            [2] => 594
        )

    [form_dropdown_VS_AGE] => 597
    [form_multiselect_VS_EDUCATION] => Array
        (
            [0] => 603
            [1] => 604
        )

    [form_text_606] => 2345
    [form_image_607] => 1045
    [form_file_607] => 1049
)
result_id If this method is called to check fields when editing the result, this parameter must indicate its ID.
Optional parameter. False by default (new result).
3.3.10
check_rights Specifies to check the current user access permissions. The following values are possible:
  • Y - check access permissions;
  • N - do not check access permissions.
To successfully check access permissions via this method, the user must have minimum access permission for [10] Web form filling for the web form, specified in the parameter form_id.
Optional parameter. Set to "Y" by default (check access permissions).
4.0.0
return_array If this parameter is not specified or set to "N", the method returns the formatted list of errors.
If set to "Y", the method returns array with error descriptions associated with specific fields. These error descriptions come with the key, equal to the field string ID, and the rest comes with numeric key. For example,
array( 
		0 => "Incorrect image captcha",
		"test_fld" => "Required fields are not specified: First field" 
		)
6.0.2

See Also

Examples of use

<?
// check input parameters and user access permissions 
// for validity  
$error = CForm::Check($FORM_ID, $_REQUEST, $RESULT_ID);

// if method didn't return error description...  
if (strlen($error)<=0) 
{
    // update the result 
    CFormResult::Update($RESULT_ID, $_REQUEST);
}
?>


© «Bitrix24», 2001-2024