function conditional_fields_field_selector in Conditional Fields 7.3
Same name and namespace in other branches
- 8 conditional_fields.module \conditional_fields_field_selector()
- 4.x conditional_fields.module \conditional_fields_field_selector()
Builds a jQuery selector from the name or id attribute of a field.
@todo support custom selectors with %lang and %key placeholders.
Parameters
$field: The field form element.
Return value
A jQuery selector string.
1 call to conditional_fields_field_selector()
- conditional_fields_form_after_build in ./
conditional_fields.module - after_build callback for forms with dependencies.
File
- ./
conditional_fields.module, line 1214 - Define dependencies between fields based on their states and values.
Code
function conditional_fields_field_selector($field) {
if (isset($field['#attributes']['name'])) {
return '[name="' . $field['#attributes']['name'] . '"]';
}
if (isset($field['#name'])) {
return '[name="' . $field['#name'] . '"]';
}
// Try with id if name is not found.
if (isset($field['#attributes']['id'])) {
return '#' . $field['#attributes']['id'];
}
if (isset($field['#id'])) {
return '#' . $field['#id'];
}
return FALSE;
}