Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

editable onchange event #258

Open
StefanHoutzager opened this issue Mar 31, 2017 · 2 comments
Open

editable onchange event #258

StefanHoutzager opened this issue Mar 31, 2017 · 2 comments

Comments

@StefanHoutzager
Copy link

See issue #216
"But what I would really like to have is a way to change the label of another element in the form depending on the input value of this select. Do you have a suggestion on how to accomplish this?"

Code for this should not be edited in a custom validation editor of course (f.e. a problem with execution serverside). It would be an enhancement to have a separate editor in the field properties for this.

@zackurben
Copy link
Contributor

This should be fairly easy with a modification to the current implementation of custom validations (shouldn't matter on the backend, if thats why you expressed concern). We just need to update the component reference and add the form too....

Actually, as I'm writing this, it may be possible already using scope.form (untested), but if my thought is correct, in the custom validator, you can do something like:

var form = scope.form;
form.components.forEach(function(component) {
  if (component.key == 'myFieldToChange') {
    component.label = 'My new Label!';
  }
});

valid = ...

We should expose the formio-utils so it's easier to traverse the component structure though..

@StefanHoutzager
Copy link
Author

Another reason why I don't want to edit this functionality in a custom validation is separation of concerns. Otherwise you open the route to hell.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants