Currently, if you use a wizard to edit an existing entity, the entity won't be in the tempstore until the "Next" button has been clicked at least once.

This is because the general model of the wizard is to not write to the tempstore until the form is submitted. For the most part this works, but if the first step (or the first step you jump to, because you can jump to any step in an edit form) opens a dialog (which isn't a step on the wizard but another form, so it pulls the cached values from the tempstore, rather than the form state temporary value), then the dialog won't have access to the entity to edit.

The way this manifests is you go to a step in the wizard, click an "Edit" link which is meant to open a dialog and nothing will happen. But if you press "Next" and then "Previous", clicking the "Edit" link will magically start working!

Comments

dsnopek created an issue. See original summary.

dsnopek’s picture

Status: Active » Needs review
StatusFileSize
new853 bytes

Here is a patch that fixes it, by initializing the cached values and setting them in the tempstore when building the form, if the cached values aren't already set.

Status: Needs review » Needs work

The last submitted patch, 2: ctools-wizard-initialize-values-2619948-2.patch, failed testing.

dsnopek’s picture

Status: Needs work » Needs review
StatusFileSize
new854 bytes

Whoa, type-o! Not sure how this worked in my manual testing, but it's great that we have tests. :-)

dsnopek’s picture

Issue tags: +Needs tests

Need to get feedback first on if this is OK, but if it is, this patch will need tests!

dsnopek’s picture

StatusFileSize
new926 bytes

New patch that works for both edit and add!

dsnopek’s picture

StatusFileSize
new1018 bytes

Moved up the call stack while hacking on it with EclipseGC.

eclipsegc’s picture

Status: Needs review » Fixed

Super sensible and fixes a long standing race condition I'd not yet tracked down. Thank you!

If you're going to write tests for this, file a follow up.

Eclipse

  • EclipseGc committed 538b295 on 8.x-3.x authored by dsnopek
    Issue #2619948 by dsnopek: Cached values not in tempstore when first...

dsnopek’s picture

Status: Fixed » Active

Gah! I just realized that this isn't enough when using in conjunction with per-operation value overrides from #2616492: Allow overriding cached values for specific operations to make it possible to use the same form class for multiple steps. Basically, the problem is that the overrides are applied to the cached values AFTER the tempstore entry is created in the WizardFactory.

In my work on page_manager, this manifests itself as allowing the "Page Access" to work (since that doesn't depend on values) but the "Selection Criteria" on a specific variant to fail. :-/

So, our nice little fix from #7 is insufficient...

eclipsegc’s picture

Status: Active » Postponed (maintainer needs more info)

So David and I discussed this at length and we'd both like to find a reproducible version of this report. Until then, I'm postponing.

Eclipse

juampynr’s picture

Is this still happening? I would need a couple screenshots to understand the issue before I could help.