Skip to content

Commit

Permalink
Merge pull request #19699 from colemanw/controlField
Browse files Browse the repository at this point in the history
APIv4 - Rename 'controlField' property to 'control_field'
  • Loading branch information
eileenmcnaughton authored Mar 1, 2021
2 parents c7ef840 + 0dcd942 commit a6ba1fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Civi/Api4/Generic/AbstractAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ protected function formatWriteValues(&$record) {
'val' => $record[$expr],
'field' => $field,
'suffix' => substr($expr, $suffix + 1),
'depends' => $field['input_attrs']['controlField'] ?? NULL,
'depends' => $field['input_attrs']['control_field'] ?? NULL,
];
unset($record[$expr]);
}
Expand Down
8 changes: 8 additions & 0 deletions Civi/Api4/Service/Spec/SpecFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ public static function setInputTypeAndAttrs(FieldSpec &$fieldSpec, $data, $dataT
}
}
}
// Ensure all keys use lower_case not camelCase
foreach ($inputAttrs as $key => $val) {
if ($key !== strtolower($key)) {
unset($inputAttrs[$key]);
$key = strtolower(preg_replace('/(?=[A-Z])/', '_$0', $key));
$inputAttrs[$key] = $val;
}
}
$fieldSpec
->setInputType($inputType)
->setInputAttrs($inputAttrs);
Expand Down
4 changes: 2 additions & 2 deletions ext/afform/core/ang/af/afField.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@

// ChainSelect - watch control field & reload options as needed
if (ctrl.defn.input_type === 'ChainSelect') {
$scope.$watch('dataProvider.getFieldData()[defn.input_attrs.controlField]', function(val) {
$scope.$watch('dataProvider.getFieldData()[defn.input_attrs.control_field]', function(val) {
if (val) {
var params = {
where: [['name', '=', ctrl.fieldName]],
select: ['options'],
loadOptions: ['id', 'label'],
values: {}
};
params.values[ctrl.defn.input_attrs.controlField] = val;
params.values[ctrl.defn.input_attrs.control_field] = val;
crmApi4($scope.dataProvider.getEntityType(), 'getFields', params, 0)
.then(function(data) {
ctrl.defn.options = data.options;
Expand Down

0 comments on commit a6ba1fe

Please sign in to comment.