Hi,

I tried to create a display suite field of the function type.
Unfortunately it didn't work for me.

After some research I found that the ds_get_field_value() function tries
to access $field['function'] which was not set by the ds_ds_fields_info()
function:

$fields[$entity_type][$key] = array(
  'title' => $field->label,
  'field_type' => $field->field_type,
  'properties' => $field->properties,
 );

So there might be two possible solutions:

1) Move the function attribute into the properties array:
$field['properties']['function']
2) Change ds_ds_fields_info to copy the file and function properties:

$fields[$entity_type][$key] = array(
  'title' => $field->label,
  'field_type' => $field->field_type,
  'properties' => $field->properties,
  'function' => $field->function,
  'file' => $field->file, 
 );

I guess the first approach is cleaner as there is already a properties array.

CommentFileSizeAuthor
ds_function_type.patch1.54 KBjantimon

Comments

swentel’s picture

Status: Needs review » Postponed (maintainer needs more info)

This works perfectly, a lot of fields use it already http://drupalcode.org/project/ds.git/blob/refs/heads/7.x-2.x:/ds.ds_fiel...

So I'm not sure what's going on here.

jantimon’s picture

Hey,

sorry I guess it was my bad. I used hook_ds_custom_fields_info instead of hook_ds_fields_info.
With hook_ds_fields_info it works as intended.

Thanks for your support.

swentel’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)