Fix parser to work with nested fields
authorColeman Watts <coleman@civicrm.org>
Fri, 1 Nov 2019 13:57:25 +0000 (09:57 -0400)
committerCiviCRM <info@civicrm.org>
Wed, 16 Sep 2020 02:13:19 +0000 (19:13 -0700)
Fields should be allowed to be inside other tags as long as they're
contained in an af-fieldset.

ext/afform/core/afform.php
ext/afform/mock/ang/testAfform.aff.html

index b1d41f5a84eae04c35f60aeb69c7c077aacf0a12..bbd0b627b08d25f02de1f37c8736018d860459c7 100644 (file)
@@ -310,7 +310,7 @@ function afform_civicrm_alterAngular($angular) {
       foreach (pq('af-field', $doc) as $afField) {
         /** @var DOMElement $afField */
         $fieldName = $afField->getAttribute('name');
-        $entityName = pq($afField)->parent('[af-fieldset]')->attr('af-fieldset');
+        $entityName = pq($afField)->parents('[af-fieldset]')->attr('af-fieldset');
         if (!preg_match(';^[a-zA-Z0-9\_\-\. ]+$;', $entityName)) {
           throw new \CRM_Core_Exception("Cannot process $path: malformed entity name ($entityName)");
         }
index 824054eb4c460be0140978d24dd0a5249332b006..8e5e52ea73e519b92cdaf091fd69da511b4b3a29 100644 (file)
@@ -7,8 +7,10 @@
   <div af-fieldset="parent">
     <h3>About You</h3>
 
-    <af-field name="first_name" />
-    <af-field name="last_name" />
+    <div class="af-block">
+      <af-field name="first_name" />
+      <af-field name="last_name" />
+    </div>
     <af-field name="gender_id" />
     <af-field name="constituent_information.Marital_Status" />
     <af-field name="constituent_information.Marriage_Date" />