Problem/Motivation
I was testing this module out just by doing something silly with loading an entity, fetcing a field value and setting the node title to the extracted value. I'm getting the error when clicking the action button.
Error: Object of class Drupal\Core\TypedData\Plugin\DataType\StringData could not be converted to string in Drupal\eca_field_widget_actions\Plugin\Action\SetWidgetValue->execute() (line 62 of /var/www/html/web/modules/contrib/eca_field_widget_actions/src/
Steps to reproduce
Here's my exported config:
uuid: 112bca29-ce1c-46b3-b970-d82bd2d818ab
langcode: en
status: true
dependencies:
config:
- field.field.node.page.field_test
- field.storage.node.field_test
- user.role.administrator
module:
- eca_content
- eca_field_widget_actions
- modeler_api
- user
third_party_settings:
modeler_api:
modeler_id: workflow_modeler
data: 'hash:1c9cbdcef7a0722f856db18efb4e87ea'
label: 'Field Widget Action'
version: 1.0.0
id: field_widget_action
weight: 0
template: false
events:
eca_field_widget_4xeidwwk:
plugin: 'eca_field_widget_actions:eca_field_widget'
label: 'ECA Field Widget'
configuration: { }
successors:
-
id: add_a_role_to_the_selected_users_vsnlqoz7
condition: ''
conditions: { }
gateways: { }
actions:
add_a_role_to_the_selected_users_vsnlqoz7:
label: 'Add a role to the selected users'
plugin: user_add_role_action
configuration:
rid: administrator
successors:
-
id: entity_load_yhhxogaz
condition: ''
entity_load_yhhxogaz:
label: 'Entity: load'
plugin: eca_token_load_entity
configuration:
token_name: ''
from: id
entity_type: node
entity_id: '9'
revision_id: ''
properties: ''
langcode: _interface
latest_revision: true
unchanged: false
object: my_entity
successors:
-
id: entity_get_field_value_32l6f727
condition: ''
entity_get_field_value_32l6f727:
label: 'Entity: get field value'
plugin: eca_get_field_value
configuration:
field_name: field_test
token_name: my_field
object: my_entity
successors:
-
id: set_field_widget_value_e8euumku
condition: ''
set_field_widget_value_e8euumku:
label: 'Set field widget value'
plugin: eca_set_field_widget_value
configuration:
widget_value: '[my_field:0:title]'
successors: { }
Proposed resolution
When debugging $value, i'm see a typed data object. So on this line: https://git.drupalcode.org/project/eca_field_widget_actions/-/blob/1.0.x...
It appears, we should be doing $value = $value->getValue()
I'm not sure if thats actually the appropriate fix as on line 50 it's also doing that but wasn't sure what DataTransferObject is without digging in deeper.
Issue fork eca_field_widget_actions-3588314
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
apmsooner commentedComment #5
ishani patel commentedHello,
I've raised MR,
Please check and review it.