I've created a custom field in Display Suite using this code in my module:
function mymodule_ds_fields_info($entity_type) {
$fields = array();
$fields['node']['type_label'] = array(
'title' => t('Label'),
'field_type' => DS_FIELD_TYPE_FUNCTION,
'function' => 'mymodule_ds_field_type_label',
);
function mymodule_ds_field_type_label($field) {
$entity = $field['entity'];
$content = $entity->type;
return $content;
}
Now, I was able to set the content of the field to match my content type, but I also want to set a dynamic class for this field equal to that content type, for example:
$fields['node']['type_label'] = array(
'title' => t('Label'),
'field_type' => DS_FIELD_TYPE_FUNCTION,
'function' => 'mymodule_ds_field_type_label',
'class' => 'CONTENTTYPE',
);
Or:
function mymodule_ds_field_type_label($field) {
$entity = $field['entity'];
$content = $entity->type;
$class = $entity->type;
So the end result should be something like this:
<div class="field field--name-type-label field--type-ds CONTENTTYPE">...</div>
How can I do this?
Thanks in advance.