I'm using editable views in a views form for a non-core entity (entityform).

In my case I have multiple number fields per row I want to be able to edit using this.
(Imagine like you want to give a "rating" to the entityform in various areas)

So.. after some usage I noticed that if a field has a validation error (in my case if its outside min/max allowed values), the only field that will become "red" (will have an error) will be the first field of the row, even if that field is correct.

After some digging in module's code I noticed that in editableviews_entity_form_validate, for each row, each field checks if each other field has any error. That caused the first field to trigger like it was the one that had the error, and not any other.

I also noticed this comment in the code:

// This is ugly, but only FieldAPI field handlers need this. The
// alternative would be for the editableviews_handler_field_field_edit
// handler's edit_form_validate() method to detect whether it's the
// last FieldAPI field handler for the current entity, which would be
// messier.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Zekvyrin created an issue. See original summary.

Zekvyrin’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.07 KB

To fix that I implemented something different than what mentioned.. I added a check and that sends in the field handler only the errors assosiated with the field (for each field).

Status: Needs review » Needs work

The last submitted patch, 2: editableviews-validate-proper-fields-2797827-2.patch, failed testing.

Zekvyrin’s picture

Uploaded wrong patch.. :/
re-uploading..

Zekvyrin’s picture

Status: Needs work » Needs review
joachim’s picture

Status: Needs review » Needs work

Thanks for the patch!

So is this fixing your original problem?

> So.. after some usage I noticed that if a field has a validation error (in my case if its outside min/max allowed values), the only field that will become "red" (will have an error) will be the first field of the row, even if that field is correct.

The 'This is ugly...' comment block needs to be moved so it sits above the 'if (method_exists' line, as that's what it's referring to.

Zekvyrin’s picture

Status: Needs work » Needs review
FileSize
1.74 KB

@joachim: Yes, that fixes the issue.

Moved the comment with new patch.

  • joachim committed 0cd951c on 7.x-1.x authored by Zekvyrin
    Issue #2797827 by Zekvyrin: Fixed FieldAPI validation.
    
joachim’s picture

Status: Needs review » Fixed

Ok. Committed.

Thanks!

Status: Fixed » Closed (fixed)

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