Skip to content

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

@shoaibshrafi

Description

@shoaibshrafi

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'
    	       }
       }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions