mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-04 08:47:59 +02:00
ENHANCEMENT: allow to check for any changed fields on the DataObject, this is expected behaviour when isChanged function is called without parameters (#5421, patch by walec51)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@103047 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
7037afc879
commit
9ac7da146b
@ -2060,13 +2060,18 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* Uses {@link getChangedFields()} to determine if fields have been changed
|
* Uses {@link getChangedFields()} to determine if fields have been changed
|
||||||
* since loading them from the database.
|
* since loading them from the database.
|
||||||
*
|
*
|
||||||
* @param string $fieldName Name of the database field
|
* @param string $fieldName Name of the database field to check, will check for any if not given
|
||||||
* @param int $changeLevel See {@link getChangedFields()}
|
* @param int $changeLevel See {@link getChangedFields()}
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isChanged($fieldName, $changeLevel = 1) {
|
function isChanged($fieldName = null, $changeLevel = 1) {
|
||||||
$changed = $this->getChangedFields(false, $changeLevel);
|
$changed = $this->getChangedFields(false, $changeLevel);
|
||||||
return array_key_exists($fieldName, $changed);
|
if(!isset($fieldName)) {
|
||||||
|
return !empty($changed);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return array_key_exists($fieldName, $changed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user