When a node form does not submit cleanly and comes back with a validation error, the expected context disappears. The reason is that context_form_alter() is not being invoked.

I'll take a stab at a patch.

Comments

alex_b’s picture

Assigned: alex_b » Unassigned
Status: Active » Needs review
StatusFileSize
new975 bytes

This approach adds an addtional validation callback that sets the context for the validation step.

There may be some other forms that suffer from the same problem. I haven't done research into that.

darrenmothersele’s picture

Version: 6.x-2.0-beta7 » 6.x-3.0-beta1
StatusFileSize
new1.17 KB

This is also an issue on v3. Patch needs to be altered slightly to make this work, attached.

wik’s picture

subscribing

blakehall’s picture

Just an FYI (and so I can keep tabs on this patch), the patch in #1 works for me with Context-2.x

NaX’s picture

patch on #1 worked for me using Context 6.x-2.0.

yhahn’s picture

Assigned: Unassigned » yhahn
Priority: Normal » Critical
rsvelko’s picture

patch tested and works on context 3.0 also

version = "6.x-3.0"

adr_p’s picture

StatusFileSize
new910 bytes

This is a patch I've applied for the 3.0 version.

steven jones’s picture

Version: 6.x-3.0-beta1 » 6.x-3.x-dev
Assigned: yhahn » steven jones
Status: Needs review » Needs work

Normally I'd do such a condition in an #after_build, so I might look into doing it that way instead.

steven jones’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Assigned: steven jones » Unassigned
Status: Needs work » Patch (to be ported)

Fixed in 6.x. Thanks!

febbraro’s picture

Status: Patch (to be ported) » Closed (cannot reproduce)

I can't reproduce this in D7 so since the form processing got a bit of an overhaul I'm inclined to think (and my debugging tells me) that context_form_alter is getting called in D7 even on a validation error (which apparently was not the case in D6 #671574: Document that hook_form_alter not called after a form fails validation).

Reopen if someone can reproduce in D7, thanks for the D6 patches.

rich.3po’s picture

Version: 7.x-3.x-dev » 6.x-3.0
Status: Closed (cannot reproduce) » Active

I'm experiencing this issue on Context 6.x.3.0 so moving to this release and re-opening.

I've tried updating to the dev release, and whereas the node form in question is now active, a multitude of other contexts are also activated which definitely should not be (and are not on the initial node form before validation errors are triggered)

For example, i have context that should only be active for a different node type, and that is being errornously triggered on my form

kevinquillen’s picture

The patch in #8 appears to work for me. I am not using the dev version.

mas5d2’s picture

Version: 6.x-3.0 » 7.x-3.x-dev

Running the latest dev version, I can confirm that context_form_alter() is not being called after validation fails. Continuing debugging....

enzipher’s picture

Status: Active » Needs review
StatusFileSize
new968 bytes

I ran into the same issue. This patch should work against latest dev.

Cheers,

nlisgo’s picture

StatusFileSize
new978 bytes

For those struggling to recreate this issue. It only seems to break on validation of existing nodes. So edit an existing node, delete an field entry that is required and submit.

I favour the after_build approach as suggested in comment #9 by Steven Jones.

Here is my patch for the latest dev.

milesw’s picture

StatusFileSize
new1.2 KB

Slightly changed #17 to fix a PHP notice due to a missing argument in the after_build function. Also left the addition of the submit handler in its original place.

tekante’s picture

Status: Needs review » Fixed

Confirmed that context was not applying to the node form on a validation error, patch from #18 applied after confirming it corrected the issue and based on other commentary. Thanks for the patch, should be included in the next dev build.

http://drupalcode.org/project/context.git/commit/e3326883f0adaa2340e0522...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.