0

I have a button (button_field) on a content type which is rendered by a view. The view will display a list of items and each will have a clickable button. When the user clicks a button, I need write a rule that will set a node reference (attached to the use) to the node that was clicked. the button_field provides several rules for detecting button clicks, but I have yet to find a rule action or rule token that gives me access to the fields on the 'node that was clicked' How do I gain access to that node?

Edit =============

Link added. I am using the actions that came with the module (no additional code added.) I was hoping when I used the 'button pressed' action, rules would give me accesses to entity:... so that I could use the fields on the entity (the one with the button that was pressed.) However, this data option is not available. Honestly, I could use flags to do this, but I thought that a flag was a bit more functionality than I needed.

  • If the button is a submit button, it depends what data is passed to the submit handler from that form. Presumably the node data is in the $form_state there. – David Thomas Jun 2 '14 at 23:12
  • I believe since you are clicking from a View and not the actual node, none of the node data is loaded, therefore none of that data is available to Rules. You could use it as a form submit with a custom module or have a link to the node instead and use the button on the node itself. – Geoff Jun 3 '14 at 0:02
  • Could you link to the module that provides button_field? Or paste your code if it's your custom solution? Also, if it is a module, but triggers your own snippet of code, one in which you need to access node, please share that snippet. – Mołot Jun 3 '14 at 6:22
  • There really is no custom code. I am creating a rule using the UI which is based on a button click. Usually when you build a rule, the system gives you a 'triggering node' variable. This does not exist when using button trigger. – Hoytman Jun 9 '14 at 15:44
0

I was trying to do something similar. It looks like as you can have button_field on any entity, you need to DEFINE what entity has button_field in your rules. It worked for me thinking like that.

What I mean is in your rules’ conditions section after checking ‘Clicked button comparison’ with your_button_field_name if you check ‘Entity is of type’ Node and ‘Content is of type’ Your_content_type, then all of the fields of your content type including nid will be available in Actions section under entity. Check out Using Button Field

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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