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

Conditional rendering of fields breaks when more than one field referencing another #288

Open
rustymcg9000 opened this issue Sep 22, 2020 · 1 comment

Comments

@rustymcg9000
Copy link

I would like a radio button with yes no to drive 2 following fields. A yes causes the first field to display and the second to hide. A no causes the first to hide and the second to display. I set this up as follows:

image

When i come to save or render I get the following error in the js console:

demo.min.js:24 Uncaught TypeError: Cannot read property 'parentElement' of null
at Object.isVisible (demo.min.js:24)
at Object.equals (demo.min.js:24)
at t.execResult (demo.min.js:24)
at demo.min.js:24
at Array.forEach ()
at demo.min.js:24
at Array.forEach ()
at demo.min.js:24
at Array.forEach ()
at demo.min.js:24

If i remove the second fields conditional statement (referencing the first radio button) the save and render returns to working

@carperei
Copy link

carperei commented Feb 22, 2024

got it working, fixes below:

renderer.js: :~238

      isNotVisible: () => {
        // fix
        let parent = elem.parentElement;
        while (!parent.parentElement.classList.contains('formeo-column')) {
            parent = parent.parentElement;
        }
        parent.setAttribute('hidden', true);
        elem.required = false // Hidden input cannot be required.
      },
      isVisible: () => {
        //fix
        let parent = elem.parentElement;
        while (!parent.parentElement.classList.contains('formeo-column')) {
            parent = parent.parentElement;
        }
        parent.removeAttribute('hidden')
        elem.required = elem._required
      },

and :270

getComponent = address => {
const componentId = address.slice(address.indexOf('.') + 1)
const component = isExternalAddress(address)
? this.external[componentId]
: this.renderedForm.querySelector([name^=f-${componentId}]) // fix
return component
}

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

2 participants