formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.89k stars 1.06k forks source link

[BUG] Address component does not render correctly in HTML mode #2075

Closed themattkenney closed 9 months ago

themattkenney commented 4 years ago

Environment

Local using latest build https://unpkg.com/formiojs@latest/dist/formio.full.min.js

Steps to Reproduce

  1. Display a form using viewAsHTML or renderMode: 'html'

Expected behavior

Should display for the submission without controls and data. No way to display only data with current builds.

Observed behavior

Example

https://jsfiddle.net/0Lvtaxes/

<div id='formio'></div>

<!-- jquery -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

<!-- bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

<!-- formio -->
<link rel='stylesheet' href='https://unpkg.com/formiojs@latest/dist/formio.full.min.css'>
<script src='https://unpkg.com/formiojs@latest/dist/formio.full.min.js'></script>

<!-- code -->
<script type='text/javascript'>
  Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/example', {
    readOnly: true,
    renderMode: 'html'
  }).then(function(form) {
    form.submission = {
      data: {
        firstName: 'Joe',
        lastName: 'Smith',
        email: 'joe@example.com'
      }
    };
  });
</script>
aiwebb commented 4 years ago

@themattkenney, here's a fork of that fiddle that redraws the form after setting the submission with those data values:

https://jsfiddle.net/qre4wj5d/

Can you clarify what you mean by controls not being removed?

themattkenney commented 4 years ago

@aiwebb in 3.X viewAsHTML would remove the controls like the renderMode: 'html' does.

I see your code addition of ' form.on('change', () => { form.redraw() })'

Is this addition required in 4.x load the values or is it a hack to get around an issue?

Thank you for showing the change as this will get me what I need.

MohitNaroliya commented 4 years ago

@aiwebb - form.redraw() works for me but the Google Address field value show as [object Object].

randallknutson commented 4 years ago

The form should probably redraw after setting the submission automatically and not require the form.redraw(). The google address must not have a good view as html rendering yet. We can look into this.

themattkenney commented 4 years ago

@randallknutson any update on if/when the address html view bug will be fixed?

jeriah-formio commented 4 years ago

@themattkenney We are hoping to get this item fixed with a new build by early next week.

themattkenney commented 4 years ago

@jhen1422 Any update on the fix for the address part?

jeriah-formio commented 4 years ago

@themattkenney We're still working on the address component working out some minor issues. I'll be sure to let you know when this has been complete and pushed.

MohitNaroliya commented 4 years ago

Hi @jhen1422 - Any update on this issue fix?

jeriah-formio commented 4 years ago

@MohitNaroliya This feature is still a work in progress.

josecristhian commented 4 years ago

Hi, the fix is going to be just for the address component or for all components when using viewAsHTML?

jeriah-formio commented 4 years ago

@josecristhian This is currently being worked on for the address component

themattkenney commented 4 years ago

@jhen1422 any update on the progress for this bug?

jeriah-formio commented 4 years ago

@themattkenney This issue is still outstanding for the Address component.

MohitNaroliya commented 4 years ago

@jhen1422 @aiwebb - Any update on this issue?

wag110894 commented 4 years ago

This item is still on our backlog. We welcome a pull request and have a process to expedite if you are interested. Please contact support@form.io if you are interested in expediting.

Thank you.

travist commented 1 year ago

I am pretty certain this PR will resolve this issue. We will close it once we pull that in and confirm.

https://github.com/formio/formio.js/pull/4745

VikkiAlenn commented 9 months ago

We assume that this issue has been already resolved with this PR https://github.com/formio/formio.js/pull/4745. Closing this thread. Please re-open if it is still relevant. Thank you for your contribution!