Have a clear error message

Because it's really annoying not knowing which field causes the error
This commit is contained in:
Thomas Portelange 2016-10-04 12:24:29 +02:00 committed by GitHub
parent f2d3026e93
commit 3d8db488d4

View File

@ -550,7 +550,12 @@ class FieldList extends ArrayList {
public function makeFieldReadonly($field) {
$fieldName = ($field instanceof FormField) ? $field->getName() : $field;
$srcField = $this->dataFieldByName($fieldName);
$this->replaceField($fieldName, $srcField->performReadonlyTransformation());
if($srcField) {
$this->replaceField($fieldName, $srcField->performReadonlyTransformation());
}
else {
user_error("Trying to make field '$fieldName' readonly, but it does not exist in the list",E_USER_WARNING);
}
}
/**