Browse Source

Merge pull request #177 from kwyss88/master

Allow Dropdown and Radio fields to be empty if they are not required
pull/158/head
Sebastian Stehle 9 years ago
committed by GitHub
parent
commit
d047d7be5b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Squidex/app/features/content/pages/content/content-page.component.ts
  2. 6
      src/Squidex/app/shared/services/schemas.service.ts

2
src/Squidex/app/features/content/pages/content/content-page.component.ts

@ -253,7 +253,7 @@ export class ContentPageComponent implements CanComponentDeactivate, OnDestroy,
fieldForm.controls[language.iso2Code].setValue(fieldValue[language.iso2Code]);
}
} else {
fieldForm.controls['iv'].setValue(fieldValue['iv']);
fieldForm.controls['iv'].setValue(fieldValue['iv'] === undefined ? null : fieldValue['iv']);
}
}

6
src/Squidex/app/shared/services/schemas.service.ts

@ -378,7 +378,11 @@ export class StringFieldPropertiesDto extends FieldPropertiesDto {
}
if (this.allowedValues && this.allowedValues.length > 0) {
validators.push(ValidatorsEx.validValues(this.allowedValues));
if (this.isRequired && !isOptional) {
validators.push(ValidatorsEx.validValues(this.allowedValues));
} else {
validators.push(ValidatorsEx.validValues(this.allowedValues.concat([null])));
}
}
return validators;

Loading…
Cancel
Save