Error when Setting Field Value on Media

Created on 24 December 2024, 4 months ago

I am experiencing an error when trying to set a field value on a media field. No matter what I do, I cannot get the desired field value to be set by ECA.

I am using paragraphs to create media. The paragraph entity has a field for the media, and another number field for the "image weight", basically to assign a value to the images when created. I have another number field "Image Weight" on the media entity.

My goal is to use ECA to set the field value on the media, based on the field value in the paragraph.

I am able to successfully retrieve the image weight using a view, and render it into the ECA rule. I can show a message using ECA, and it correctly shows the number creating by the view. The error occurs when I am setting the field value on the media. I have tried using many different variations of the settings to set the field value but everything results in errors of various types.

Here is my rule structure:

Event: Presave content entity. Type: media image
No Conditions
Action:
- Render Views
Successors
1. Successful: Display a message to the user: Weight from paragraph.
2. Fails: Set Field Value: weight from paragraph entity set to Image Weight on Media entity.

Settings:
- Method: set only when empty (Tried others without success)
- field name: field_image_weight
- Field Value: [weight]
- Entity: -empty-
- trim: false (Tried empty without success)
- Save Entity: true (Tried empty without success)

I have also tried setting the entity to "media" and various other tokens.

Error:
TypeError: round(): Argument #1 ($num) must be of type int|float, string given in round() (line 113 of /var/www/html/website/web/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php).

Thanks in advance to anyone that can help!

💬 Support request
Status

Active

Version

2.1

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024