Hello, everyone. I have two form validation callbacks that should only be triggered under a narrow set of circumstances:
$validator
->scalar('rev_distro_notes')
->notEmptyString('rev_distro_notes', 'This field is required if a PROPRIETARY or CONFIDENTIAL label is chosen', 'create', function ($context) {
$labelIds = [3,4,5,6];
return in_array($context['data']['rev_label_id'], $labelIds);
});
$validator
->scalar('label_change_info')
->notEmptyString('label_change_info', 'You must provide justification for this label change.', 'create', function ($context) {
return $context['data']['rev_label_id'] != $context['data']['curr_label_id'];
});
Both validations are triggering when the fields are left empty, even when the conditions I specify aren’t met, and they’re showing a generic “Please fill out this field” message. I don’t know what I’m missing here. Ideas?