Dependent fields with ECA

Created on 12 September 2023, over 1 year ago

Problem/Motivation

I almost fully replaced Business Rules with ECA, however missing one functionality and wondering if it is possible to achieve it with this module.

Is it possible to use dependent functionality so for example if you choose Country "Germany" in another field called "Towns" the values of select list will be updateted based on Country so I can select only towns from Germany ?

Business Rules has good manual here dependent-field β†’ how to achieve it.

It is basicly using views and in entity reference field there is an option in Reference Method called "Business rules - dependent using views". Here with ECA I can see also option "Event-based selection with ECA" but I am not sure how to use it. Is it possible to achieve the same with ECA ??

I found also ECA issue 3350438 πŸ’¬ Event like: "Field value has changed" to control state of other fields of the entity, while creating / editing entity Fixed but it is related to Conditional fields only which do not supoort dependent fields.

πŸ’¬ Support request
Status

Active

Version

1.1

Component

Documentation

Created by

πŸ‡ΈπŸ‡°Slovakia coaston

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

Comments & Activities

  • Issue created by @coaston
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    This is currently not yet possible. However, it has been raised in a different context recently, and we may well add something in the future. It's important to recognize the difference that events for are being dispatched in the backend, so that ECA can subscribe to them and take some action. What this issue is all about, are events that occur in the frontend. So, what may be an extension to ECA at some point is a framework that allows to recognize frontend-events and dispatch a backend event from them. This will then also require a framework to allow the backend to trigger some actions in the frontend as a response to such events. Maybe the already existing ajax commands are sufficient for that.

    Not really related, but since you also raised that question, the "Event-based selection with ECA" is an event that gets dispatched during auto-complete activity, where an entity reference field in the frontend requests a list of matching entities from the backend. With that event, ECA can hook into that process and alter the result.

  • πŸ‡ΈπŸ‡°Slovakia coaston

    Thank you for your answer. I hope one day there will be such feature available as it seems i am not the only one who would love to use sort of "dependent field".

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • πŸ‡ΈπŸ‡°Slovakia coaston

    Does it mean there is any progress?

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Progress so far is that we're getting ready for ECA 2.0 next week, so that new features will be going into the 2.1 branch. That's what today's update of this issue was about.

    When we will get into implementing new features depends on a lot of things, e.g. how important is it to how many users, is there any funding, do we have resources who are willing to work on this on their own time, etc.

  • Status changed to Postponed: needs info about 1 month ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    The eca_endpoint sub-module now has all the ajax commands implemented that Drupal core provides. With those, almost all interaction between frontend and backend should be possible. See the action plugins at https://ecaguide.org/plugins/eca/endpoint/

    Please give that a try if it allows you to do what you're looking for.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Missing feedback.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • πŸ‡ΈπŸ‡°Slovakia coaston

    Hi jurgenhaas,

    Sorry, I somehow didn't notice that you had replied until just now.

    I wanted to try, but not sure what I am doing wrong. I have used following example : Endpoint Test and i have updated Route Match to "entity.node.edit_form" so now when I navigate to article node/x/edit I can see message like "You are visiting "[mynode:title]" so it works for my edit form, however as you suggested there should be ajax available now, so I wanted to select TAG and display the current value, however it does not work until I save the article.

    In other words when I navigate node/x/edit and i would like to see message like "You are visiting "[mynode:title] and [mynode:field_tags]" but I can see message ""You are visiting "[mynode:title] and ..." which is fine because there is no any TAG added yet. Now I add tag with value 1 for example, but message still display "You are visiting "[mynode:title] and ..." and i need to save the node to see expected valu ["You are visiting "[mynode:title] and [mynode:field_tags]" so I cannot work dynamically with that value and possible update dependent field and ajax is not working in this case, or am I missing anything ?

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    This is a closed issue. If you want to follow-up on this, you need to create a new one. And there you need to described step by step what you're doing so that we can reproduce it. From the comment #11 nobody can tell what ECA model you've created and how there is any ajax in the game.

  • πŸ‡ΈπŸ‡°Slovakia coaston

    Thank you.

    Information for others who are facing the same problem as I am and want to replicate the 'dependent field': Here is the exact model that performs this function Eca dependent-field β†’ , and we can finally remove the rules module and use only ECA.

    Here you can find my video Eca Dependent. β†’

    Note: who needs to use Taxonomy instead of select list, just use Options instead of "11:11: anything like "[tid]:[name] so "671:Admin change"

    @jurgenhaas I believe this example can be added to eca library because i believe many users will find is useful and this feature prevented to get rid of rules as described here. β†’

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Thank you @coaston for sharing this, I'm totally impressed. This is amazing!!!

    We will certainly add this to the ECA Guide. In the meantime, I've shared this in the #ECA channel of Drupal Slack for all the others to know about it too. I wanted to mention you in that post but you don't seem to be on Drupal Slack?

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Hey @coaston, one more question: what version of ECA have you been using when exporting this model? I'm asking because the node type config file contains properties that make it difficult to import the model on existing sites. and that issue has been fixed back in June last year. So, your ECA version appears to be older than that?

  • πŸ‡ΈπŸ‡°Slovakia coaston

    You're right. In my local environment, I have about 10 different test sites, and this particular one is quite old, using an older Drupal 9 or 10 version. But if needed, I can recreate it, as it's very easy to set up.

    I'm also impressed because I've been missing this feature for almost two years, and I have sites in production that couldn't be migrated from Drupal 9 to 10 because there's no stable release of the Business Rules module. So now we can finally migrate to Drupal 10.

Production build 0.71.5 2024