1. Created a component with condition as Node is of type.
2. Changed data selector for the condition 'Node' to @node.node_route_context:node (NOTE: The list of data selector available to rules for the same condition in reaction rules is not available when creating a component, so had to choose this.)
3. Entered a value in the 'Check for the the allowed node types' textarea.
4. Created an action for the component.
5. Tried to create a reaction rule from the component.

Get this PHP error while saving the reaction rule!

Warning: Invalid argument supplied for foreach() in Drupal\rules\Form\Expression\ActionForm->getContextConfigFromFormValues() (line 111 of modules/contrib/rules/src/Form/Expression/ContextFormTrait.php).
Drupal\rules\Form\Expression\ActionForm->getContextConfigFromFormValues(Object, Array) (Line: 136)
Drupal\rules\Form\Expression\ActionForm->submitForm(Array, Object) (Line: 100)
Drupal\rules\Form\EditExpressionForm->buildComponent(Array, Object) (Line: 118)
Drupal\rules\Form\EditExpressionForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 83)

I can save again successfully, But when the rule gets triggered , i get this php error.

arning: preg_match_all() expects parameter 2 to be string, array given in Drupal\rules\TypedData\PlaceholderResolver->scan() (line 186 of modules/contrib/rules/src/TypedData/PlaceholderResolver.php).
Drupal\rules\TypedData\PlaceholderResolver->scan(Array) (Line: 63)
Drupal\rules\Plugin\RulesDataProcessor\TokenProcessor->process(Array, Object) (Line: 294)
Drupal\rules\Plugin\RulesExpression\RulesCondition->processData(Object, Object) (Line: 85)
Drupal\rules\Plugin\RulesExpression\RulesCondition->prepareContext(Object, Object) (Line: 108)
Drupal\rules\Plugin\RulesExpression\RulesCondition->executeWithState(Object) (Line: 46)
Drupal\rules\Plugin\RulesExpression\RulesAnd->evaluate(Object) (Line: 73)
Drupal\rules\Engine\ConditionExpressionContainer->executeWithState(Object) (Line: 90)
Drupal\rules\Plugin\RulesExpression\Rule->executeWithState(Object) (Line: 92)
Drupal\rules\Plugin\RulesAction\RulesComponentAction->execute() (Line: 93)
Drupal\rules\Plugin\RulesExpression\RulesAction->executeWithState(Object) (Line: 41)
Drupal\rules\Plugin\RulesExpression\ActionSet->executeWithState(Object) (Line: 94)
Drupal\rules\Plugin\RulesExpression\Rule->executeWithState(Object) (Line: 41)
Drupal\rules\Plugin\RulesExpression\ActionSet->executeWithState(Object) (Line: 131)
Drupal\rules\EventSubscriber\GenericEventSubscriber->onRulesEvent(Object, 'rules_entity_update:node', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('rules_entity_update:node', Object) (Line: 140)
rules_entity_update(Object)

Thanks,
Sukanya

Comments

sukanya.ramakrishnan created an issue. See original summary.

Anonymous’s picture

I just got this error too from doing something different but after just speaking to @klausi here at DrupalCon I understand the UI side of Rules isn't really there yet so there may be a number of issues underneath this one.

Sounds like there's going to be some stuff done on Rules this week so perhaps some movement yay, will help where I can but not sure this particular issue is easy to fix - YMMV etc.

sukanya.ramakrishnan’s picture

Thanks !, I am actually wondering about how to get data for the data selector for components? Would someone be able to help?

Thanks
Sukanya

TR’s picture

Status: Active » Closed (duplicate)

Thanks !, I am actually wondering about how to get data for the data selector for components? Would someone be able to help?

#2916331: Passing variables from rules to components and back

The error in the original post is because there is currently no UI for configuring component inputs. This is part of "Milestone 3" of the porting roadmap #2245015: [META] Rules 8.x Roadmap