Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field is excluded in the Alpaca.getValue() when dependent on hidden field #771

Open
shoaibshrafi opened this issue Jun 15, 2022 · 0 comments

Comments

@shoaibshrafi
Copy link

shoaibshrafi commented Jun 15, 2022

Following is the code in alpaca.js version 1.5.27 Line number 24336 to 24344
Any one know the reason to not include the field that is dependent on hidden field although hidden field value included in the value

I think following check should be removed.

//
// NESTED HIDDENS DEPENDENCY HIDES (ALPACA EXTENSION)
//

// final check: only set valid if the dependentOnPropertyId is showing
if (dependentOnField && dependentOnField.isHidden())
{
       valid = false;
 }

return valid;

as per following example field2 value is not included in the alpaca.getValue() and getting value as {'field1': 'Value1'} instead of {'field1': 'Value1', 'field2': '100'}

var alpaca = $('#form').alpaca();
var value = alpaca.getValue();

Here is the json schema:

{
	"$schema":"https://json-schema.org/draft/2020-12/schema",
	"$id":"https://gso.org.sa/aajel/api/json/schema?version=1",
	"description":"Here is custom  form generated by json schema using alpaca",
	"type":"object",
	"dependencies": {
    	"field2": ["field1"]
	},
	"properties":{
		"field1": {
			"type":"string",
			"enum":[
				"Value1",
				"Value2"
			]
		},
		"field2":{
			"type":"string",
			"enum":[
				"100",
				"200",
				"300",
				"400"
			]
		}
	}
}	

Here is the options:

{
   "fields":{
      "field1":{"type": "hidden", "default": "Value1"},
      "field2":{
   		"dependencies": {
        	  "field1": 'Value1'
    	       }
       }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant