plomino / Plomino

Powerful and flexible web-based application builder
33 stars 37 forks source link

Values should be reset inside a hidden hidewhen #805

Closed djay closed 7 years ago

djay commented 7 years ago

User problem

Lets say you have a form with a question "do you want to enter something person yes/no" which opens a hidewhen where you enter personal data. Then you change your mind and click "no". You would not expect your answer to be there if you changed your mind and clicked yes again and you would not expect your hidden answer to be submitted. The form creator life is easier if they can rely that hidden inputs don't have unexpected values and don't have to be cleared manually.

Options to enable

First: should this behaviour be selectable per form, per hidehwhen, or change plomino.

per hidewhen

A setting on the hidewhen?

Options to reset

theme issue

Make the user do submission code and js to clear it if its important to them

store default html clientside

Some JS stores the html inside a hidewhen on load. Any hide reset the html. Server side code would need to do similar for non dynamic hidewhens on multipage.

con: might screw up any onload js for special widgets

dynamic defaults

It would be helpful to be able to have a default change based on other values. Currently this isn't possible. Mainly because the JS doesn't know how to set a value on different widgets. Each field type would have to provide some method to do this depending on the widget. Also, a field would need a way to know if the user has entered data in it so it doesn't touch data the user has selected.

With dynamic defaults, we could then determine if a hidewhen is closed on the serverside and return the default values for each of the contained fields during the dynamic hidewhens call.

ebrehault commented 7 years ago

I think the per hidewhen option would be accurate and quite easy to implement (for both static and dynamic hidewhen).

djay commented 7 years ago

@ebrehault I commited fixes for this in the advanced_ide branch

djay commented 7 years ago

@ebrehault I implemented both a serverside clear values if hidden and a client side one for dynamic hidewhens. The dynamic version works as above where it records teh html when the page is open and replaces the inner html of a hidewhen on hide. However this only works if the value to reset was not there when the page loads. The value is there in the case of a validation error or multipage.

So need to think of another way

Options

  1. widgets have reset function. Every field type and widget has some api which can reset it to a blank value or "default" for this form.

  2. during the dynamic hidewhen call, a rendered version of the inside if the hidewhen with a blank document is returned.

    • con: this call is already slow. I think this will likely need to render the whole form to get just this part. Could cache it but its still user specific since defaults can be formulas.
  3. store initial inner hidewhen html into localstorage or cookies during first viewing.