@ngx-formly/core 6.1.4 → 6.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -895,10 +895,10 @@ class FormlyField {
895
895
  if (!field) {
896
896
  return () => { };
897
897
  }
898
- const subscribes = [
899
- observeDeep(field, ['props'], () => field.options.detectChanges(field)),
900
- observeDeep(field.options, ['formState'], () => field.options.detectChanges(field)),
901
- ];
898
+ const subscribes = [observeDeep(field, ['props'], () => field.options.detectChanges(field))];
899
+ if (field.options) {
900
+ subscribes.push(observeDeep(field.options, ['formState'], () => field.options.detectChanges(field)));
901
+ }
902
902
  for (const key of Object.keys(field._expressions || {})) {
903
903
  const expressionObserver = observe(field, ['_expressions', key], ({ currentValue, previousValue }) => {
904
904
  if (previousValue === null || previousValue === void 0 ? void 0 : previousValue.subscription) {
@@ -1706,28 +1706,35 @@ class FieldExpressionExtension {
1706
1706
  }
1707
1707
  }
1708
1708
  evalExpr(field, prop, value) {
1709
- try {
1710
- let target = field;
1711
- const paths = this._evalExpressionPath(field, prop);
1712
- const lastIndex = paths.length - 1;
1713
- for (let i = 0; i < lastIndex; i++) {
1714
- target = target[paths[i]];
1715
- }
1716
- target[paths[lastIndex]] = value;
1717
- }
1718
- catch (error) {
1719
- error.message = `[Formly Error] [Expression "${prop}"] ${error.message}`;
1720
- throw error;
1721
- }
1722
- if (['templateOptions.disabled', 'props.disabled'].includes(prop) && hasKey(field)) {
1723
- this.changeDisabledState(field, value);
1724
- }
1725
1709
  if (prop.indexOf('model.') === 0) {
1726
- const key = prop.replace(/^model\./, ''), control = (field === null || field === void 0 ? void 0 : field.key) === key ? field.formControl : field.form.get(key);
1710
+ const key = prop.replace(/^model\./, ''), parent = field.fieldGroup ? field : field.parent;
1711
+ let control = (field === null || field === void 0 ? void 0 : field.key) === key ? field.formControl : field.form.get(key);
1712
+ if (!control && field.get(key)) {
1713
+ control = field.get(key).formControl;
1714
+ }
1715
+ assignFieldValue({ key, parent, model: field.model }, value);
1727
1716
  if (control && !(isNil(control.value) && isNil(value)) && control.value !== value) {
1728
1717
  control.patchValue(value);
1729
1718
  }
1730
1719
  }
1720
+ else {
1721
+ try {
1722
+ let target = field;
1723
+ const paths = this._evalExpressionPath(field, prop);
1724
+ const lastIndex = paths.length - 1;
1725
+ for (let i = 0; i < lastIndex; i++) {
1726
+ target = target[paths[i]];
1727
+ }
1728
+ target[paths[lastIndex]] = value;
1729
+ }
1730
+ catch (error) {
1731
+ error.message = `[Formly Error] [Expression "${prop}"] ${error.message}`;
1732
+ throw error;
1733
+ }
1734
+ if (['templateOptions.disabled', 'props.disabled'].includes(prop) && hasKey(field)) {
1735
+ this.changeDisabledState(field, value);
1736
+ }
1737
+ }
1731
1738
  this.emitExpressionChanges(field, prop, value);
1732
1739
  }
1733
1740
  emitExpressionChanges(field, property, value) {
@@ -1942,6 +1949,9 @@ class FieldFormExtension {
1942
1949
  }
1943
1950
  addFormControl(field) {
1944
1951
  let control = findControl(field);
1952
+ if (field.fieldArray) {
1953
+ return;
1954
+ }
1945
1955
  if (!control) {
1946
1956
  const controlOptions = { updateOn: field.modelOptions.updateOn };
1947
1957
  if (field.fieldGroup) {