Closed (fixed)
Project:
Rules
Version:
7.x-2.x-dev
Component:
Rules Core
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 Oct 2011 at 11:40 UTC
Updated:
2 Nov 2012 at 15:43 UTC
Despite reading around in code + documentation + examples, and quite a few attempts, I am unable to use the 'getter callback' for new data types in a proper way.
Situation: I want to use a custom function for retrieving a property for a custom data type. Kind of like this.
/**
* Defines info for the properties of the views_display data structure.
*/
function _rb_views_views_display_info() {
return array(
'field' => array(
'type' => 'list<views_field>',
'label' => t('Fields'),
'getter callback' => 'my_custom_function',
),
);
}
Problem: Every time I add the 'getter callback' entry, I get fatal errors on my site. (White screen, no messages shown. I should turn on my error messages, by the way.)
Wanted: A description of how to use 'getter callback', and 'setter callback'. I suspect that there may be problems if the object they act on has internal callbacks, but I'm not sure.
Comments
Comment #1
itangalo commentedOk, error output now turned on.
Fatal error: Call to undefined function my_custom_functoin() in …/sites/all/modules/entity/includes/entity.wrapper.inc on line 444It seems weird that I should have to do an explicit exclude of the file with the function – it is the same file declaring the properties of the custom data type. (rb_views.rules.inc)
I'll keep on looking…
Comment #2
itangalo commentedOk. Moving the callback function to the main .module file does the trick.
Still curious about how/if I can add files to include for a particular data type, but I'll pass that question for now. Case closed!
Comment #3
charlie-s commentedI believe you need to include the reference to the include in your module.info file so that it's loaded during bootstrap, e.g.:
...
Comment #4
itangalo commentedAh, smart. Thanks.
Comment #6
gollyg commentedSo the typo
my_custom_functoinwas not contributing to the issue?Comment #7
charlie-s commentedGood catch. That was probably a problem, too, but OP has likely fixed.