There is a problem with triggering entity level validation constraints in multivalue forms.

Comments

dbolinovski created an issue. See original summary.

dbolinovski’s picture

Assigned: Unassigned » dbolinovski
Status: Active » Needs review
StatusFileSize
new1.45 KB
dbolinovski’s picture

Extend the cases in which the validation runs without setting the #ief_submit_all flag on subform buttons.

slashrsm’s picture

Thank you! Patch looks good. Just one thing (which is more a comment than something to fix).

+++ b/src/InlineEntityForm/EntityInlineEntityFormHandler.php
@@ -179,8 +179,15 @@ class EntityInlineEntityFormHandler implements InlineEntityFormHandlerInterface
+      $arrayParents = $triggering_element['#array_parents'];
+      $cnt = count($arrayParents);
+      $canValidate = in_array($arrayParents[$cnt - 1], ['ief_add_save', 'ief_edit_save']);
+    }

I dislike the fact that handler needs to be aware of field widget specific knowledge. Bad separation of responsibilities.

However, there is already one such case in same class and I don't see any other viable option so we don't have any other choice I guess.

bojanz’s picture

Status: Needs review » Fixed

Tweaked and committed; http://cgit.drupalcode.org/inline_entity_form/commit/?id=64affce

We can pursue cleanups in followups.

  • bojanz committed 64affce on 8.x-1.x authored by dbolinovski
    Issue #2568255 by dbolinovski: Entity level validation constraints in...

Status: Fixed » Closed (fixed)

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