State API doesnt work when using this module

Created on 21 April 2023, over 1 year ago
Updated 6 June 2024, 5 months ago

Problem/Motivation

I have different fields at different steps based on steps prior to current step the user is in

Steps to reproduce

for example in a BuildForm I have this states applied to one of the fields

       $form['deal_uri']['#states'] = [
            'visible' =>
            [
                ':input[name="local_store"]' => ['value' => false],
            ],
        ];

After I made the field group to form step it doesnt take the states api into consideration.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom q8tywolf

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

Comments & Activities

  • Issue created by @q8tywolf
  • 🇪🇨Ecuador dmezquia UTC-5

    I think that it is not possible (in the current logic) to use the #states for the fields that are not in the same step (check) (for those that are in the same step if it works well), the fields that are not in the same step are not shown and therefore it cannot be done check with the #states.

    I think you should look for another alternative like:

    - Save the content entity (node, etc) in each step and thus be able to validate with the fields saved from the previous step.
    - Find another way to save the previous step temporarily etc, to be able to validate in a next step.

    PS: I uploaded a Merge Request Allow Alter MultistepController Fixed that allows changing the MultiStepController, this gives greater flexibility when adding or modifying custom requirements.

  • 🇮🇳India aarti zikre

    thank you dmezquia for checking this issue. However, for the required State it is still not working for those that are in the same step. Please let me know if anything different we need to do for required state.

    Thanks,
    Aarti

  • 🇪🇨Ecuador dmezquia UTC-5

    Hi, right now I really don't have a solution for this problem, maybe I can review it soon depending on the available time I have, I would start by looking at what I mentioned in comment #2.

    Maybe if you think of any solution, comment it or upload an MR, patch.

Production build 0.71.5 2024