public static function FieldHelper::getFieldsByType in Helper 7
Return an array of fields with a certain type.
Parameters
string $type: The type of field to look for.
Return value
array An array of field names.
1 call to FieldHelper::getFieldsByType()
File
- lib/
FieldHelper.php, line 85
Class
Code
public static function getFieldsByType($type) {
$fields_by_type = array();
if ($cache = cache_get('field_info:helper_fields_by_type', 'cache_field')) {
$fields_by_type = $cache->data;
}
else {
foreach (field_info_fields() as $field) {
$fields_by_type[$field['type']][] = $field['field_name'];
}
cache_set('field_info:helper_fields_by_type', $fields_by_type, 'cache_field');
}
return !empty($fields_by_type[$type]) ? $fields_by_type[$type] : array();
}