
- #DRUPAL RULES UPDATE FIELD ON SAVE HOW TO#
- #DRUPAL RULES UPDATE FIELD ON SAVE PATCH#
- #DRUPAL RULES UPDATE FIELD ON SAVE CODE#
Before you are tempted to use VBO for processing them all at once. For example, you can create a form using the Address Field module to collect user addresses with properly formatted address fields that change dynamically for each country the user may select. The action needs an array, you entered an object. This means you have entered a value of the wrong data type. What Ive ended up doing is creating two 'dummy' date fields for DAY BEFORE and DAY AFTER, and Im trying to hook into the form, grabbing the event date, using some PHP like strtotime() to add/subtract a day, and make these the values that would go into the database.

Therefor you might want to also watch the video about " More details about VBO settings". The Entityform module allows you to build forms using any available fields from Drupal core or contributed modules. Argument 1 passed to DrupalrulesPluginRulesActionSystemSendEmail::doExecute() must be of the type array, object given. node:fieldeventdate-datetime -1 day as the scheduled time. If you want even more, then also watch the subsequent " Using Rules components with more than one parameter" video.Īttention: to process like 100.000 entities at once is quite a challenge (memory requirements, etc). To get the idea, have a look at the video about Using Rules components with VBO" which uses a Rules Component with (only) 1 parameter. Use it in conjuction with the Workflow state has changed event to create a rule that will, on a particular state change, schedule a subsequent change.
#DRUPAL RULES UPDATE FIELD ON SAVE PATCH#
Here is the patch to add the Schedule a Workflow transition to the available actions in workflowrules. In doing so, you'll then be able to use the Rules Component from Step 1. workflowrules-scheduletransitionaction-2217017-1.patch.
#DRUPAL RULES UPDATE FIELD ON SAVE HOW TO#
Then transform that view into a view that uses Views Bulk Operations, and use the technique documented in " How to use Rules to create a custom bulk operation for a VBO view?". Step 2Ĭreate a view of the nodes for which those fields should be added.
#DRUPAL RULES UPDATE FIELD ON SAVE CODE#
In this case, you have to set the value for both the Number and Currency Code properties.Use the Rules module to create a Rules Component, which includes whatever Rules Conditions you might need (if any), and with a Rules Action to Set a data value, for each of those fields you want to be updated. $entity->field_price->currency_code = 'EUR' To set the value of a Price field you can do this: $entity->field_price->number = 10 You can see the price field's property definition here. But here, i cannot find inside the data selector any of the fields i have on the webform. For example, the Price field in Drupal Commerce has more than one property. access the values of the webform fields using rules, for that i did: EVENT: After saving new webform submission (rulesentityinsert:webformsubmission) ACTION: Set a data value. You can't use the short way if you have a field type with multiple properties. $entity->field_name_multi = Are there any exceptions?

You can use this: $entity->field_name_muti = So, instead of this: $entity->field_name_muti->value = When the event is 'Update content entity' while the entity is set to create a new revision and the action changes that entity, we get the following exception: DrupalCoreEntityEntityStorageException: Update existing node entity revision while changing the revision ID is not supported. The same also applies if you don't use the set () method: $entity->field_name = $another_entity What about programmatically updating multi-value fields? When a bug report is set to closed, you can no longer add or remove a flag (via trapping and undoing the flag operation.

Situation: I have a node type 'Bug report' with a flag (module) 'confirm' and a cck field 'Status' which can be 'Open' or 'Closed'. Here is a straight bug report on the issue I ended up hitting. It's worth mentioning that for entity reference fields instead of the entity ID you could set the entity object like this: $entity->set('field_name', $another_entity) The last issue related to this was a mess of different theories and situations.

Somehow, this looks and feels much better in my opinion. That's a shorter way to write the same thing, which is good, but I personally prefer using the set() method like this: $entity->set('field_name', 'foo') Just like the majority of people in his poll, I also didn't know that you could shorten this: $entity->field_name->value = 'foo'
