JSON Forms: Clear Field value on change of checkboxes

Dear Forum,

I had defined a JSON Form providing two checkbockes and a text field.

During the initialization of the form, or after selecting a user in a dnlookup filed,  the text filed is initialized with an attribute value of the selected user, and if any checkbox is changed, the value of the filed is cleared.

This was working until IDM 4.8.7, but after the update to 4.9 the value was only sometimes removed.

Can anybody provide a general idea, how to ensure, the text field is cleared on any change of any checkbox?

I can remember there is a way to fire a custom event on the change of one element, and listen on this event to trigger the clearing of the text field, but I cannot remember how to do this in JSON forms.

Kind regards

Thorsten

  • 0

    hi, I might have done it in a too complicated way -> I added a hidden field that is responsible to execute a custom logic when value stored within is different than the one on the  relevant component (logic will set the new value and execute all the required activity, like cleaning fields)

  • 0 in reply to 

    Hi,

    I was trying to adapt to this way, but it is still not working by 100%

    I have two hidden fields providing the "old" and initial value of the checkboxes, and I added a custom logic to my text field to clear it, whenever the hidden field value is not equal to the value of the checkbox. 

    But this deleted the value of the text-fiied during initialization as well - at one stage I was not even capable to edit the filed, because it was deleted after each keystroke!

    First I was thinking a custom event fired on the change of a checkbox would be the solution, but if this event is triggered during the initialization of the checkboxes as well, It would not work either!

    Is it possible to distinguish between an interactive change of a component or the setting by a JS, which is executed on the change of another field (selecting a user)?

    Kind regards

    Thorsten

  • Verified Answer

    +1 in reply to 

    I was more thinking of a field for storing the state of the checkboxes in order to detect when it changes, like here
    jsfiddle.net/.../

  • 0 in reply to 

    Hi,

    thanks for this code example - it is working, as long as inactively changing the boxes, but this code deletes the value of the text filed on the initialization of the form as well.

    I believe the default value of checkbox_control_hidden should be set to the values of the checkboxes after initialization and not to "false:false"

    BTW: In the current Form Builder ()IDM 4.9) it is not possible to define a default value in the UI, it has to be done in the JSON code for some reason!

    I will try to implement this ;-)

    Kind regards

    Thorsten

  • 0 in reply to 

    HI,

    I managed to set the hidden field providing the "last" status of all checkboxes along with the other hidden fields, when initializining the form. Now it is working as desigend, I guess!

    The only strange thing is, I cannot see the value of the new hidden field changing, like on the other hidden fileds (whit modal edit enabled)  - But since this is only ment for debugging, I belive this case is solved ;-)

    Cheers

    Thorsten