function hook_conditional_fields_states_alter in Conditional Fields 7.3
Alter the list of states available for dependent fields.
These are the jQuery events that are executed when a dependent field changes state (that is, when the dependency changes from untriggered to triggered or vice-versa).
To implement a new state, it is necessary to create a jQuery event with the same name, prepended by the "state:" namespace. E.g.:
$(document).bind('state:STATE_NAME', function(e) { if (e.trigger) { // e.value is true if the conditions are satisfied, false otherwise... } });
Parameters
$states: An associative array of states.
1 invocation of hook_conditional_fields_states_alter()
- conditional_fields_states in ./
conditional_fields.module - Builds a list of supported states that may be applied to a dependent field.
File
- ./
conditional_fields.api.php, line 27 - Hooks provided by Conditional Fields.
Code
function hook_conditional_fields_states_alter(&$states) {
// Add a new Form state to the list. The corresponding jQuery event might
// look like this:
// $(document).bind('state:addmyclass', function(e) {
// if (e.trigger) {
// $(e.target).toggleClass('myclass', e.value);
// }
// });
$states['addmyclass'] = t('With CSS class myclass');
// Converse states are obtained by prepending an exclamation mark to the name.
// They are automatically implemented by the States API, but you need to add
// them explicitly to the list to make them available in the UI.
$states['!addmyclass'] = t('Without CSS class myclass');
// A configurable state. The class can be configured implementing an effect
// (see example in hook_conditional_fields_effects_alter).
$states['addclass'] = t('With CSS class');
$states['!addclass'] = t('Without CSS class');
}