CBPHelper :: GetFieldInputValue: Bitrix method

      
<?php 
//  CBPHelper :: GetFieldInputValue()
//  /dist/bitrix/modules/bizproc/classes/general/helper.php:1430

    
public static function GetFieldInputValue($documentType$arFieldType$arFieldName$arRequest, &$arErrors)
    {
        
$result = [];

        if (
$arFieldType["Type"] == "user")
        {
            
$value $arRequest[$arFieldName["Field"]];
            if (
strlen($value) > 0)
            {
                
$result CBPHelper::UsersStringToArray($value$documentType$arErrors);
                if (
count($arErrors) > 0)
                {
                    foreach (
$arErrors as $e)
                    {
                        
$arErrors[] = $e;
                    }
                }
            }
        }
        elseif (
array_key_exists($arFieldName["Field"], $arRequest) || array_key_exists($arFieldName["Field"]."_text"$arRequest))
        {
            
$arValue = [];
            if (
array_key_exists($arFieldName["Field"], $arRequest))
            {
                
$arValue $arRequest[$arFieldName["Field"]];
                if (!
is_array($arValue) || is_array($arValue) && CBPHelper::IsAssociativeArray($arValue))
                {
                    
$arValue = array($arValue);
                }
            }
            if (
array_key_exists($arFieldName["Field"]."_text"$arRequest))
            {
                
$arValue[] = $arRequest[$arFieldName["Field"]."_text"];
            }

            foreach (
$arValue as $value)
            {
                if (!
CBPActivity::isExpression($value))
                {
                    if (
$arFieldType["Type"] == "int")
                    {
                        if (
strlen($value) > 0)
                        {
                            
$value str_replace(" """$value);
                            if (
$value."|" == intval($value)."|")
                            {
                                
$value intval($value);
                            }
                            else
                            {
                                
$value null;
                                
$arErrors[] = array(
                                    
"code" => "ErrorValue",
                                    
"message" => GetMessage("BPCGWTL_INVALID1"),
                                    
"parameter" => $arFieldName["Field"],
                                );
                            }
                        }
                        else
                        {
                            
$value null;
                        }
                    }
                    elseif (
$arFieldType["Type"] == "double")
                    {
                        if (
strlen($value) > 0)
                        {
                            
$value str_replace(" """str_replace(",""."$value));
                            if (
$value."|" == doubleval($value)."|")
                            {
                                
$value doubleval($value);
                            }
                            else
                            {
                                
$value null;
                                
$arErrors[] = array(
                                    
"code" => "ErrorValue",
                                    
"message" => GetMessage("BPCGWTL_INVALID11"),
                                    
"parameter" => $arFieldName["Field"],
                                );
                            }
                        }
                        else
                        {
                            
$value null;
                        }
                    }
                    elseif (
$arFieldType["Type"] == "select")
                    {
                        if (!
is_array($arFieldType["Options"]) || count($arFieldType["Options"]) <= || strlen($value) <= 0)
                        {
                            
$value null;
                        }
                        elseif (!
array_key_exists($value$arFieldType["Options"]))
                        {
                            
$value null;
                            
$arErrors[] = array(
                                
"code" => "ErrorValue",
                                
"message" => GetMessage("BPCGWTL_INVALID35"),
                                
"parameter" => $arFieldName["Field"],
                            );
                        }
                    }
                    elseif (
$arFieldType["Type"] == "bool")
                    {
                        if (
$value !== "Y" && $value !== "N")
                        {
                            if (
$value === true)
                            {
                                
$value "Y";
                            }
                            elseif (
$value === false)
                            {
                                
$value "N";
                            }
                            elseif (
strlen($value) > 0)
                            {
                                
$value strtolower($value);
                                if (
in_array($value, array("y""yes""true""1")))
                                {
                                    
$value "Y";
                                }
                                elseif (
in_array($value, array("n""no""false""0")))
                                {
                                    
$value "N";
                                }
                                else
                                {
                                    
$value null;
                                    
$arErrors[] = array(
                                        
"code" => "ErrorValue",
                                        
"message" => GetMessage("BPCGWTL_INVALID45"),
                                        
"parameter" => $arFieldName["Field"],
                                    );
                                }
                            }
                            else
                            {
                                
$value null;
                            }
                        }
                    }
                    elseif (
$arFieldType["Type"] == "file")
                    {
                        if (
array_key_exists("name"$value) && strlen($value["name"]) > 0)
                        {
                            if (!
array_key_exists("MODULE_ID"$value) || strlen($value["MODULE_ID"]) <= 0)
                                
$value["MODULE_ID"] = "bizproc";

                            
$value CFile::SaveFile($value"bizproc_wf"true);
                            if (!
$value)
                            {
                                
$value null;
                                
$arErrors[] = array(
                                    
"code" => "ErrorValue",
                                    
"message" => GetMessage("BPCGWTL_INVALID915"),
                                    
"parameter" => $arFieldName["Field"],
                                );
                            }
                        }
                        else
                        {
                            
$value null;
                        }
                    }
                    else
                    {
                        if (!
is_array($value) && strlen($value) <= 0)
                            
$value null;
                    }
                }

                if (
$value != null)
                    
$result[] = $value;
            }
        }

        if (!
$arFieldType["Multiple"])
        {
            if (
count($result) > 0)
                
$result $result[0];
            else
                
$result null;
        }

        return 
$result;
    }