(af-field) Rename "field-name" to "name"
authorTim Otten <totten@civicrm.org>
Fri, 13 Sep 2019 16:55:26 +0000 (12:55 -0400)
committerCiviCRM <info@civicrm.org>
Wed, 16 Sep 2020 02:13:19 +0000 (19:13 -0700)
ext/afform/core/CRM/Afform/ArrayHtml.php
ext/afform/core/Civi/Api4/Action/Afform/Prefill.php
ext/afform/core/afform.php
ext/afform/core/ang/af/Fieldset.js
ext/afform/core/ang/afField/afField.js
ext/afform/core/ang/afField/widgets/CheckBox.html
ext/afform/docs/sandbox/planning-v0.3.md
ext/afform/mock/ang/afex.aff.html
ext/afform/mock/tests/phpunit/api/v4/formatExamples/banana.php

index 7c24e5303588b49562898391154661754f03aeef..acf0ac6fcc09039f455140ebdc256f5e2283fdef 100644 (file)
@@ -27,7 +27,7 @@ class CRM_Afform_ArrayHtml {
       'data' => 'js',
     ],
     'af-field' => [
-      'field-name' => 'text',
+      'name' => 'text',
       'defn' => 'js',
     ],
     'af-fieldset' => [
index f3adcead23d7c37c62c5c293b516b41cca7ab5e7..0a05e550de133af615ff2e67cc9875b319a1d7c6 100644 (file)
@@ -46,7 +46,7 @@ class Prefill extends AbstractProcessor {
     }
     $result = civicrm_api4($entity['type'], 'get', [
       'where' => [['id', '=', $id]],
-      'select' => array_column($entity['fields'], 'field-name'),
+      'select' => array_column($entity['fields'], 'name'),
       'checkPermissions' => $checkPermissions,
     ]);
     if ($result->first()) {
index 714196b319dbadc602587a5e3a9f194896a72245..ae148d8bd081400f90a8e4966be6d03d83f0131f 100644 (file)
@@ -181,7 +181,7 @@ function afform_civicrm_alterAngular($angular) {
 
       foreach (pq('af-field', $doc) as $afField) {
         /** @var DOMElement $afField */
-        $fieldName = $afField->getAttribute('field-name');
+        $fieldName = $afField->getAttribute('name');
         $entityName = pq($afField)->parent('af-fieldset[af-name]')->attr('af-name'); // TEST ME
         if (!preg_match(';^[a-zA-Z0-9\_\-\. ]+$;', $entityName)) {
           throw new \CRM_Core_Exception("Cannot process $path: malformed entity name ($entityName)");
index 60b61e0942c9415a1a71aea7662f0beaf2cd7440..6afe95b664cc318b2425fb56a47897e639828e53 100644 (file)
@@ -12,7 +12,7 @@
         $scope.afFormCtrl = afFormCtrl;
         // This is faster than waiting for each field directive to register itself
         $('af-field', $el).each(function() {
-          afFormCtrl.registerField($scope.afName, $(this).attr('field-name'))
+          afFormCtrl.registerField($scope.afName, $(this).attr('name'))
         });
       },
       controller: function($scope){
index 63b79967f6049d2b3bd88bf89a99c1550aa80804..fb618405af5e4d05221374dbbf31830d5da3fe9a 100644 (file)
@@ -1,12 +1,12 @@
 (function(angular, $, _) {
-  // Example usage: <af-fieldset af-name="myModel"><af-field field-name="do_not_email" /></af-fieldset>
+  // Example usage: <af-fieldset af-name="myModel"><af-field name="do_not_email" /></af-fieldset>
   angular.module('afField').directive('afField', function() {
     return {
       restrict: 'E',
       require: ['^afFieldset', '^afForm'],
       templateUrl: '~/afField/afField.html',
       scope: {
-        fieldName: '@',
+        fieldName: '@name', // TEST ME
         defn: '='
       },
       link: function($scope, $el, $attr, ctrls) {
index f652a022da4074bec88e5ae1068e66ff1afd05b7..bf0bd8bb9e6a044a77f03b3ed029cf1ef59918ba 100644 (file)
@@ -1,6 +1,6 @@
 <ul class="crm-checkbox-list" id="{{ fieldId }}" ng-if="defn.options">
   <li ng-repeat="(key, val) in defn.options" >
-    <input type="checkbox" checklist-model="getData()[fieldName]" id="{{ fieldId + key }}" checklist-value="key" />
+    <input type="checkbox" checklist-model="getData()[name]" id="{{ fieldId + key }}" checklist-value="key" />
     <label for="{{ fieldId + key }}">{{ val }}</label>
   </li>
 </ul>
index e8ea3ab28773c308b9b6bab846596f614d00d18e..d7daf040cc081b4a09205bb98268e15d7603207a 100644 (file)
       <af-fieldset af-name="parent">
         <af-std-contact-name label="Name" />
         <af-std-contact-email label="Email" />
-        <af-field field-name="do_not_email" field-type="checkbox" field-default="1" />
+        <af-field name="do_not_email" field-type="checkbox" field-default="1" />
       </af-fieldset>
     </crm-ui-tab>
     <crm-ui-tab title="Spouse">
       <af-fieldset af-name="spouse">
         <af-std-contact-name label="Spouse Name" />
         <af-std-contact-email label="Spouse Email" only-primary="true" />
-        <af-field field-name="do_not_email" field-type="checkbox" field-default="1" />
+        <af-field name="do_not_email" field-type="checkbox" field-default="1" />
       </af-fieldset>
     </crm-ui-tab>
   </crm-ui-tab-set>
index ef5d156df5d5e198946d4548adff891dbc3dc555..edbd2b3baeb894ac097b85e16bc865ba96a4b2b8 100644 (file)
@@ -9,13 +9,13 @@
   <af-fieldset af-name="parent">
     <af-block-contact-name label="My Name" />
     <af-block-contact-email label="My Email" />
-    <af-field field-name="do_not_email" />
+    <af-field name="do_not_email" />
   </af-fieldset>
 
   <af-fieldset af-name="spouse">
     <af-block-contact-name label="Spouse Name" />
     <af-block-contact-email label="Spouse Email" only-primary="true" />
-    <af-field field-name="do_not_email" field-type="checkbox" field-default="1" />
+    <af-field name="do_not_email" field-type="checkbox" field-default="1" />
   </af-fieldset>
 
   <af-fieldset af-name="home">
index 5d3441133efca71b5023a6b0d3da8bee26b8adb0..af5c134adf9e891ffd6c3f0a6691749b6bcba423 100644 (file)
@@ -1,19 +1,19 @@
 <?php
 
 return [
-  'html' => '<div><strong>New text!</strong><af-field field-name="do_not_sms" defn="{label: \'Do not do any of the emailing\'}"></af-field></div>',
+  'html' => '<div><strong>New text!</strong><af-field name="do_not_sms" defn="{label: \'Do not do any of the emailing\'}"></af-field></div>',
   'shallow' => [
     '#tag' => 'div',
     '#children' => [
       ['#tag' => 'strong', '#children' => ['New text!']],
-      ['#tag' => 'af-field', 'field-name' => 'do_not_sms', 'defn' => "{label: 'Do not do any of the emailing'}"],
+      ['#tag' => 'af-field', 'name' => 'do_not_sms', 'defn' => "{label: 'Do not do any of the emailing'}"],
     ],
   ],
   'deep' => [
     '#tag' => 'div',
     '#children' => [
       ['#tag' => 'strong', '#children' => ['New text!']],
-      ['#tag' => 'af-field', 'field-name' => 'do_not_sms', 'defn' => ['label' => 'Do not do any of the emailing']],
+      ['#tag' => 'af-field', 'name' => 'do_not_sms', 'defn' => ['label' => 'Do not do any of the emailing']],
     ],
   ],
 ];