Not sure if it's possible without throwing a validation error, but it'd be great if we could highlight the affected fields when reporting about modifications or conflicts.

I wonder if we could even just mark conflicting fields with form_set_error() but still allow the user to resubmit with the "invalid" value to overwrite?

Comments

bdragon’s picture

The problem with form_set_error() is the form doesn't get rebuilt if there are errors. I think doing some of the stuff that #ajax does regarding messing with the cached form might work as a workaround though.

mitchell’s picture

Version: » 7.x-1.x-dev

> highlight the affected fields when reporting about modifications or conflicts.
What about saving another revision and redirecting to a Diff view? Also, Revisioning is able to support nodes (not entities) in multiple states.

There was also this early stage Conflict Resolver module that might help a tiny bit.

cweagans’s picture

Assigned: Unassigned » cweagans

Per https://association.drupal.org/node/18268, a dev is needed here. I'll run with this.

drumm’s picture

Conflict Resolver is D6 only, it likely won't help.

I don't really want to install Revisioning just for this.

Saving another revision and using Diff sounds complicated.

I think we should keep this simple and within Conflict module. If there is a way to use the existing Form API error styles during build, that should be okay.

cweagans’s picture

Assigned: cweagans » Unassigned

So another project landed on my plate and I'm not going to be able to get to this for a while. If somebody else wants to pick it up and run with it, go for it. Otherwise, I'll circle back and take a look in a week or two.

drumm’s picture

Issue tags: -drupal.org D7 +Drupal.org 7.1

Moving out of the launch priorities since this feature can be deployed whenever it is committed to conflict module.

drumm’s picture

(tag)

m1r1k’s picture

Here is patch, pure form_set_error() does the jobs.

tvn’s picture

Status: Active » Needs review
Issue tags: +drupal.org szeged sprint
drumm’s picture

Status: Needs review » Needs work

This completely prevents the form from being saved. The "Save again to overwrite it." part of the error message should work as it says. See also comment #1.

Can we set the error class or otherwise mark it in the $form array?

m1r1k’s picture

Yes, my bad. Here is patch with pure highlighting through 'error' class

m1r1k’s picture

Status: Needs work » Needs review
drumm’s picture

Status: Needs review » Needs work
      // Will add error highlighting for text fields
      $form[$field_name][$langcode][0]['#attributes']['class'][] = 'error';
      // Will add error highlighting for list fields: radios, checkboxes, multiple term reference, etc
      $form[$field_name][$langcode]['#attributes']['class'][] = 'error';

Do we really want to always set both? Actually, this might want to iterate over all the children, for multiple-item fields.

bdragon’s picture

Thinking out loud:

function _conflict_apply_error(&$elements) {
 // Recurse through all children.
  foreach (element_children($elements) as $key) {
    if (isset($elements[$key]) && $elements[$key]) {
      _conflict_apply_error($elements[$key]);
    }
  }
  // If there are properties, it's probably safe to set #attributes here.
  if (!empty(element_properties($elements)) {
    $elements['#attributes']['class'][] = 'error';
  }
}
m1r1k’s picture

Assigned: Unassigned » m1r1k
Status: Needs work » Needs review
StatusFileSize
new1.71 KB
new2.71 KB
elijah lynn’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.72 KB
new1.75 KB

Appears to work so far!

Added some doc corrections and marked RTBC because they are so minor.

sun’s picture

Status: Reviewed & tested by the community » Needs work

Let's add unit and/or integration tests here.

This module continues to cause lots of pain for d.o. Root cause is a total lack of tests.

tvn’s picture

Assigned: m1r1k » Unassigned

m1r1k, please, re-assign to yourself if you are planning to work on this.

m1r1k’s picture

Assigned: Unassigned » m1r1k
Issue tags: +Amsterdam2014
m1r1k’s picture

Status: Needs work » Needs review
StatusFileSize
new14.5 KB
new16.17 KB

Here is fixed version with tests.

drumm’s picture

Why was this change made?

         // Checksum the data so it's directly comparable.
-        $sum[$k] = md5(serialize($f[$k]));
+        $sum[$k] = $f[$k];
drumm’s picture

StatusFileSize
new15.67 KB

Attached is an untested re-roll.

drumm’s picture

(This will likely need another re-roll, #2210937: Conflict module over-reporting conflicts during crosspost, preventing issue updates incorrectly covers some of the same changes in a different way, that looks more thorough.)

drumm’s picture

StatusFileSize
new15.4 KB

Another untested re-roll.

Status: Needs review » Needs work

The last submitted patch, 24: 1599490.diff, failed testing.

drumm’s picture

StatusFileSize
new15.18 KB

Improved re-roll, I missed some now-redundant code.

drumm’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 26: 1599490.diff, failed testing.

drumm’s picture

StatusFileSize
new15.22 KB

It looks like the messages are correct with manual testing. They may be swapped around in the test.

This patch replaces

    // Force reload the node.
    node_load($conflict->nid, NULL, TRUE);

in testComplexTroublesCase(), to be sure it isn't a cache problem.

drumm’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 34: 1599490.diff, failed testing.

drumm’s picture

Status: Needs work » Needs review
StatusFileSize
new15.77 KB

This corrects the Title field label in _conflict_get_node_changes(). "Node" should not appear in UI text, and the tests test for that.

Status: Needs review » Needs work

The last submitted patch, 37: 1599490.diff, failed testing.

drumm’s picture

Status: Needs work » Needs review
StatusFileSize
new15.9 KB

I think the new diff algorithm was detecting the difference between NULL and an empty string in the Body's summary. The UI will never generate a NULL summary, so this sets it to an empty string in drupalCreateNode().

  • drumm committed b0f19c3 on 7.x-1.x authored by m1r1k
    #1599490 Highlight modified and conflicting fields during conflict...
drumm’s picture

Status: Needs review » Fixed

That's better. Thanks for the thorough tests!

drumm’s picture

Issue tags: +needs drupal.org deployment
drumm’s picture

Issue tags: -needs drupal.org deployment

Now deployed on Drupal.org.

Status: Fixed » Closed (fixed)

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