Skip to content

Instantly share code, notes, and snippets.

@hansek hansek/atLeastOneOf

Last active Aug 29, 2015
What would you like to do?
atLeastOneOf - MODX FormIt Hook : at least one of validated field have to be correct
* atLeastOneOf
* Custom MODX FormIt hook to check if at least one of defined field is correctly filled
* !!! To proper work have to be set on last validate field (phone in example)
* Usage example:
* &customValidators=`atLeastOneOf`
* &validate=`name:required,
* email:email:required,
* phone:required:atLeastOneOf=^email|phone^`
$one_of = explode('|', $param);
$any_error = true;
foreach ($one_of as $one_key) {
if (!array_key_exists($one_key, $errors)) {
$any_error = false;
if (!$any_error) {
foreach ($one_of as $one_key) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.