Skip to content

Commit

Permalink
Merge pull request #178 from formio/FIO-9244-Radio-component-with-All…
Browse files Browse the repository at this point in the history
…ow-only-available-values-checked-does-not-submit

FIO-9244: fixed an issue where Radio component with Allow only available values checked does not submit
  • Loading branch information
brendanbond authored Oct 23, 2024
2 parents 47c1e0e + dc79aaa commit 46e413a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,11 @@ describe('validateAvailableItems', function () {
context.fetch = () => {
return Promise.resolve({
ok: true,
json: () => Promise.resolve(['1', '2', '3']),
json: () => Promise.resolve([
{ label: '1', value: '1' },
{ label: '2', value: '2' },
{ label: '3', value: '3' },
]),
});
};
const result = await validateAvailableItems(context);
Expand All @@ -501,7 +505,11 @@ describe('validateAvailableItems', function () {
context.fetch = () => {
return Promise.resolve({
ok: true,
json: () => Promise.resolve(['1', '2', '3']),
json: () => Promise.resolve([
{ label: '1', value: '1' },
{ label: '2', value: '2' },
{ label: '3', value: '3' },
]),
});
};
const result = await validateAvailableItems(context);
Expand Down
5 changes: 4 additions & 1 deletion src/process/validation/rules/validateAvailableItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ export const validateAvailableItems: RuleFn = async (context: ValidationContext)
? null
: error;
}
return values.find((optionValue) => optionValue === value) !== undefined ? null : error;
return values.find((optionValue) => optionValue.value === value || optionValue === value) !==
undefined
? null
: error;
}

return null;
Expand Down

0 comments on commit 46e413a

Please sign in to comment.