You are here

function hook_conditional_fields_conditions_alter in Conditional Fields 7.3

Alter the list of conditions available as dependee states.

These are callbacks that are executed by the States API to check if a dependee field matches the required condition. Modules adding conditions using this hook should also add the corresponding callback to the Drupal.states.Trigger.states object.

Parameters

$conditions: An associative array of conditions, with names as keys and labels as values.

1 invocation of hook_conditional_fields_conditions_alter()
conditional_fields_conditions in ./conditional_fields.module
List of states of a dependee field that may be used to evaluate a condition.

File

./conditional_fields.api.php, line 110
Hooks provided by Conditional Fields.

Code

function hook_conditional_fields_conditions_alter(&$conditions) {

  // Add a special condition that checks if a field value is an integer greater
  // than 0. The javascript callback could be something like:
  // Drupal.states.Trigger.states.positiveInteger = {
  //   'keyup': function () {
  //     var val = this.val(),
  //         int = parseInt(val);
  //     return val == int && int > 0;
  //   }
  // };
  $conditions['positiveInteger'] = t('An integer greater than 0.');

  // Like states, conditions get a converse automatically.
  $conditions['!positiveInteger'] = t('An integer less than or equal to 0.');
}