You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.
I have writing a function to handle it. I’m sharing it in case it’s useful to others. It still depends on knowing all possible values, but they’re saved once in an array rather than being coded at each call. So now only the OR vals are coded at each call.
functionredux_required( $compare_field = '', $all_values = array(), $exclude_values = array(), $comparison = '!=', $inc_empty = TRUE ) {
/* * When $comparison is != this effectively works as an OR for the $exclude_values */if ( empty( $compare_field ) || empty( $all_values ) ) {
$return = array();
} else {
if ( $inc_empty ) {
$return = array( array( $compare_field, $comparison, '' ) );
$i = 1;
} else {
$return = array();
$i = 0;
}
foreach ( $all_valuesas$k => $v ) {
if ( ! in_array( $k, $exclude_values ) ) {
$return[ $i ++ ] = array( $compare_field, $comparison, $k );
}
}
}
return$return;
}
Then you just check if one of the values in the ‘required’ array is boolean true, if it is change your lookup logic to seek any of the values being matched.
ok @dovy. Looked at the code (v3). I think it’s pretty easy.
Where you’ve got $return = $this->compareValueDependencies(...
You just need to track and pass the existing state and whether it’s an “ANY” case or “ALL” case. Thus you could do something like…
if ($any_all=='ANY') {
$return = $current_state || $this->compareValueDependencies(...;
} else {
$return = $current_state && $this->compareValueDependencies(...; // Just did it this way for consistency
}
More details hopefully to be provided by @chrishoward.
The text was updated successfully, but these errors were encountered:
Suggestion by @chrishoward on slack.
I have writing a function to handle it. I’m sharing it in case it’s useful to others. It still depends on knowing all possible values, but they’re saved once in an array rather than being coded at each call. So now only the OR vals are coded at each call.
And the call looks something like this…
In Redux, I’d suggest keeping it simple. Just adding an ANY (i.e. OR) parameter.
Then you just check if one of the values in the ‘required’ array is boolean true, if it is change your lookup logic to seek any of the values being matched.
ok @dovy. Looked at the code (v3). I think it’s pretty easy.
Where you’ve got
$return = $this->compareValueDependencies(...
You just need to track and pass the existing state and whether it’s an “ANY” case or “ALL” case. Thus you could do something like…
More details hopefully to be provided by @chrishoward.
The text was updated successfully, but these errors were encountered: