Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am using Rules 7.x-2.2 with the latest version of Button Field (http://drupal.org/project/button_field), Session API (http://drupal.org/project/session_api) and a custom module to store some entity values in a user's session when they click a button.

To clarify, I have an entity type (Commerce product) with an HTML instance of the button field that is supposed to trigger a custom defined rules action, where I want to extract some values from the entity object that the button is associated with.

This is how my Rules action info looks currently in my custom module:

function commerce_custom_box_rules_action_info() {
    return array(
        'commerce_custom_box_add_to_box' => array(
            'group' => t('Commerce Custom Box'),
            'label' => t("Add the product to the user's box"), 
            'parameter' => array(
                'entity' => array(
                    'label' => t('Product entity'),
                    'description' => t('The entity the clicked button is attached to.'),
                    'type' => 'entity',
                ),
            ),
        ),
    );
}

And here is how my rule looks:

Rule utilising custom action

The problem is, in commerce_custom_box_add_to_box() (the function fired by my custom action), I have tried using dpm() on all of its arguments and none of them contain any entity properties, field values, or anything else that could even be remotely useful. All I get are empty "EntityDrupalWrapper" objects and similar. However, if I replace the action in the rule with "Execute PHP Code", there is an $entity object available there and dpm() reveals that it is in fact populated with all the usual properties.

Naturally I am trying to figure out why that object is there but isn't being received by my custom action. Perhaps I'm thinking about it in the wrong way?

A fresh pair of eyes on this would be hugely appreciated! Happy to provide more info if needed.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

It turns out this was caused by the parameter type I used. I set it to "entity", whereas it should be the machine name of the entity type. Changing it to "commerce_product" has fixed the problem.

share|improve this answer
    
thanks for posting your solution –  Stan Ascher Nov 8 '13 at 14:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.