'data' => 'js',
],
'af-field' => [
- 'field-name' => 'text',
+ 'name' => 'text',
'defn' => 'js',
],
'af-fieldset' => [
}
$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()) {
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)");
$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){
(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) {
<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>
<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>
<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">
<?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']],
],
],
];