Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have created simple entity and trying to output data with Views.
There is a property with 'integer' type.
function test_entity_api_entity_property_info() {
$info = array();
$properties = &$info['test_entity']['properties'];
$properties = array(
'test_option' => array(
'label' => t('Test Option'),
'description' => t('Test Option.'),
'type' => 'integer',
'schema field' => 'test_option',
'options list' => 'test_entity_api_test_option_options_list',
),
);
return $info;
}
function test_entity_api_test_option_options_list() {
return array(t('Pending'), t('Accepted'), t('Declined'));
}
Works like a charm!
I can use fields and set up filters. Options list works great here.
But now I would like to output value from option list using options list callback.
There is a problem. Views simply doesn't see properties with 'list' type.
'test_option' => array(
'label' => t('Test Option'),
'description' => t('Test Option.'),
'type' => 'list', // this is not working...
'schema field' => 'test_option',
'options list' => 'test_entity_api_test_option_options_list',
)
May be I doing something wrong?
Thanks for any help!
Comments
Comment #1
haggins CreditAttribution: haggins commentedI have the same problem. My property is of type
list<int>
. In general, it contains just a serialized array of numbers.But it's not available in views. Did I use the
list<>
type wrong or did I miss anything?Unfortunately, I found no example for implementing list properties for comparison.
Its setter and getter callback are as follows:
Comment #2
maen CreditAttribution: maen commentedFor those who are as talented as me:
I made the first working by changing the optionlist.
Views can see it.
Comment #3
milos.kroulik CreditAttribution: milos.kroulik commentedI may be wrong, but I think, that it's because there is no Entity API alternative to
views_handler_field_serialized
field handler. So maybe it's really a feature request?