mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Added BankAccountField::is_valid_array_structure() to avoid PHP Notices when converting empty array values
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64305 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
c8c9c2166d
commit
dada15629a
@ -71,7 +71,23 @@ class BankAccountField extends FormField {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Checks for a valid array structure.
|
||||
*
|
||||
* @param array $arr
|
||||
* @return boolean
|
||||
*/
|
||||
protected static function is_valid_array_structure($arr) {
|
||||
return (
|
||||
is_array($arr)
|
||||
&& array_key_exists('BankCode', $arr)
|
||||
&& array_key_exists('BranchCode', $arr)
|
||||
&& array_key_exists('AccountNumber', $arr)
|
||||
&& array_key_exists('AccountSuffix', $arr)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getBankCode() {
|
||||
@ -217,8 +233,10 @@ JS;
|
||||
$valueArr['AccountNumber'],
|
||||
$valueArr['AccountSuffix']
|
||||
) = explode(" ",$value);
|
||||
} else {
|
||||
} elseif(self::is_valid_array_structure($value)) {
|
||||
$valueArr = $value;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(strlen(trim($valueArr['AccountNumber'])) == 7) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user