function conditional_fields_states_handler_link_addressfield in Conditional Fields 7.3
States handler for links provided by the Addressfield module.
File
- ./
conditional_fields.module, line 1898 - Define dependencies between fields based on their states and values.
Code
function conditional_fields_states_handler_link_addressfield($field, $field_info, $options, &$state) {
if ($options['values_set'] != CONDITIONAL_FIELDS_DEPENDENCY_VALUES_WIDGET) {
return;
}
$regex = $options['values_set'] == CONDITIONAL_FIELDS_DEPENDENCY_VALUES_REGEX;
$keys = array();
if ($field['#handlers']['address']) {
$keys += array(
'country',
'thoroughfare',
'premise',
'postal_code',
'locality',
'administrative_area',
);
}
if ($field['#handlers']['organisation']) {
$keys += array(
'organisation_name',
);
}
if ($field['#handlers']['name-oneline']) {
$keys += array(
'name_line',
);
}
elseif ($field['#handlers']['name-full']) {
$keys += array(
'first_name',
'last_name',
);
}
$addressfield_selectors = array();
foreach ($keys as $key) {
$addressfield_selectors[str_replace('%key', $key, $options['selector'])] = array(
'value' => $regex ? $options['value'] : $options['value'][0][$key],
);
}
$state = array(
$options['state'] => $addressfield_selectors,
);
}