SFDigitalServices / formio-sfds

The form.io theme for sf.gov
https://formio-sfds.herokuapp.com/
MIT License
15 stars 2 forks source link

The "language" option is overridden by DOM lang attributes #161

Closed shawnbot closed 3 years ago

shawnbot commented 3 years ago

I ran into this trying to get the new shared components example in #160 to respect the language option from the query string. The problem is that if any element above the form in the DOM has a lang attribute, its value overrides the language option passed in explicitly to the form constructor.

This example would alert "en" rather than "zh":

<html lang="en">
  <div id="form"></div>
  <!-- formio.js + formio-sfds here -->
  <script>
    Formio.createForm(document.getElementById('form'), 'https://sfds.form.io/foo', {
      language: 'zh'
    }).then(form => alert(form.options.language))
  </script>
</html>