Can't make custom action for webform_fields

Created on 20 February 2021, almost 4 years ago
Updated 6 May 2023, over 1 year ago

Problem/Motivation

I'm trying to create a custom action that will use fields from a webform submission, but I'm unable to specify an action context of webform_fields without getting an error when adding the context. E.g., I have an action defined as

<?php

namespace Drupal\process_trial\Plugin\RulesAction;

use Drupal\rules\Core\RulesActionBase;

/**
 * Provides a 'ProcessTrial' action.
 *
 * @RulesAction(
 *  id = "process_trial",
 *  label = @Translation("Process trial"),
 *  category = @Translation("Process Trial"),
 *  context = {
 *     "Webform Fields" = @ContextDefinition("webform_fields",
 *       label = @Translation("WebformFields"),
 *       description = @Translation("Fields in Webform submission")
 *     ),
 *  }
 * )
 */
class ProcessTrial extends RulesActionBase {

  /**
   * {@inheritdoc}
   */
  public function doExecute($object) {
    dpm($object, 'Object');
  }
}

When I then try to add a 'Process Trial' action, and click 'Switch to data selection', I get an immediate error of

InvalidArgumentException: Invalid values given. Values must be represented as an associative array. in Drupal\Core\TypedData\Plugin\DataType\Map->setValue() (line 76 of /home/newpe/public_html/web/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php).

Steps to reproduce

Create an action, as above in a module, and add that action to a role, then click 'Switch to data selection'

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Closed: outdated

Version

1.5

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Ben Coleman

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024