protected function afterValidate()
{
$contra_flags = array('_unable_to_assess', '_eye_missing');
foreach (array('left', 'right') as $side) {
$check = 'has' . ucfirst($side);
if ($this->{$check}()) {
if ($this->{$side . '_readings'}) {
foreach ($this->{$side . '_readings'} as $i => $reading) {
if (!$reading->validate()) {
foreach ($reading->getErrors() as $fld => $err) {
$this->addError($side . '_readings', ucfirst($side) . ' reading(' . ($i + 1) . '): ' . implode(', ', $err));
}
}
}
foreach ($contra_flags as $f) {
if ($this->{$side . $f}) {
$this->addError($side . $f, 'Cannot be ' . $this->getAttributeLabel($side . $f) . ' with VA readings.');
}
}
} else {
$valid = false;
foreach ($contra_flags as $f) {
if ($this->{$side . $f}) {
$valid = true;
}
}
if (!$valid) {
$this->addError($side, ucfirst($side) . ' side has no data.');
}
}
}
}
parent::afterValidate();
}