Hello Team,
I’m facing some issue while adding multiple rule conditions to a field.
Lets take an example.
const schema = {
type: “object”,
properties: {
name: {
type: “string”,
},
age: {
type: “string”,
},
occupation: {
type: “string”,
},
location: {
type: “string”,
},
workMode: {
type: “string”,
},
},
};
const uiSchema = {
type: “VerticalLayout”,
elements: [
{
type: “Control”,
scope: “#/properties/name”,
},
{
type: “Control”,
scope: “#/properties/occupation”,
},
{
type: “Control”,
scope: “#/properties/location”,
},
{
type: “Control”,
scope: “#/properties/workMode”,
},
{
type: “Control”,
scope: “#/properties/age”,
rule: {
effect: “DISABLE”,
condition: {
type: “AND”,
conditions: [
{
type: “LEAF”,
scope: “#/properties/name”,
expectedValue: “John”,
},
{
type: “LEAF”,
scope: “#/properties/location”,
expectedValue: “Australia”,
},
],
},
},
},
],
};
Based on this uischema, whenever I type “John” in name field and “Australia” in location field, Age field is getting disabled.
lets say, I want to disable occupation field, if workMode is not equal to “wfh” and location is not equal to “test”. I have tried with below uiSchema. what it does is occupation field is always disabled, even if workMode is “wfh” and location is “test”,
I expected occupation field is supposed to be enabled if workMode is “wfh” and location is “test”.
how can we achieve this by changing rule of occupation field in uiSchema?
const uiSchema = {
type: “VerticalLayout”,
elements: [
{
type: “Control”,
scope: “#/properties/name”,
},
{
type: “Control”,
scope: “#/properties/occupation”,
rule: {
effect: “DISABLE”,
condition: {
type: “AND”,
conditions: [
{
type: “NOT”,
condition: {
type: “EQUALS”,
scope: “#/properties/workMode”,
expectedValue: “wfh”,
},
},
{
type: “NOT”,
condition: {
type: “EQUALS”,
scope: “#/properties/location”,
expectedValue: “test”,
},
},
],
},
},
},
{
type: “Control”,
scope: “#/properties/location”,
},
{
type: “Control”,
scope: “#/properties/workMode”,
},
{
type: “Control”,
scope: “#/properties/age”,
},
],
};
Thank you in Advance
Suseen