-
Notifications
You must be signed in to change notification settings - Fork 533
Visible parameter #149
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
Labels
Comments
I had the same issue.
var conditionValue = function(model, field, oldVal) {
/*
example of format for condition
[
{"model":"id", "value":true},
{"model":"color", "value":"red"}
]
*/
var conditions = field.condition;
/*
score will help to decide if all condition are true
for every condition, if true, you get 1 point
if total score if equal the number of conditions, the conditions are validated
here it will be score/condition.length, so 2/2 for a validation
This is only an example, there is better ways to do this logic
*/
var score = 0;
for (var i = 0; i < condition.length; i++) {
if (model[condition[i].model] === condition[i].value) {
score++;
}
}
if (score === condition.length) {
// all condition validated, field is visible
return true
} else {
// not a perfect score, fields is not visible
return false
}
} In you function that prepare the schema, you then just need to associate All of this is just an example, you can much more with the logic and the value you get. Good luck ! |
Thanks, nice solution. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I am building the schema in a PHP array then convert it to JSON for the front-end. The problem is that the function will be wrapped in quote so it won't work.
PHP array
Generated JSON
1- Is it possible I can simply pass a array for visibility and it detects the visibility.
2- I assume first option is not possible but is there any way for passing function as I explained above?
The text was updated successfully, but these errors were encountered: