Support condition plugins that have AJAX callbacks

Created on 24 May 2024, 6 months ago

Problem/Motivation

This is being opened stemming from πŸ› fields of bundle are not loaded when using Context UI Needs review .

Any condition plugins that try to use AJAX can encounter this problem. When an AJAX callback happens, addCondition is triggered. Since the condition id is in the context when you add it, addCondition throws an HttpException. It seems there is no way around this from the plugin form level.

Steps to reproduce

Forms with AJAX (like Entity Field Condition) will fail (see the patch https://www.drupal.org/project/entity_field_condition/issues/3278442#com... πŸ› fields of bundle are not loaded when using Context UI Needs review ) for two reasons. One, the callbacks must support the context of either a block form or a context form (both structures are different). This patch fixes that in the module, but then triggers this issue of addCondition being called on every form rebuild.

Proposed resolution

Instead of throw an HttpException, wrap the addCondition logic around if the condition id has been added or not and either redirect the form or allow the AJAX to complete. This still prevents it from being added again AFAICT without breaking the form.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs review

Version

5.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kevinquillen

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024