Skip to content

Editing a submission with an xforms-value-changed action fires update on load #648

@garethbowen

Description

@garethbowen

Expected Behaviour

The xforms-value-changed event should only fire when the value has been changed after the form has loaded. So when loading a form for editing a submission which already has values set, the action should not fire.

Observed Behaviour

The action fires on load and updates the value.

Reproduction Steps

Form (XML or XLSX file):

<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:odk="http://www.opendatakit.org/xforms" xmlns:orx="http://openrosa.org/xforms">
  <h:head>
    <h:title>Value changed event</h:title>
    <model>
      <instance>
        <data id="xforms-value-changed-event">
          <source/>
          <destination/>
          <meta>
            <instanceID />
          </meta>
        </data>
      </instance>
      <bind nodeset="/data/destination" type="dateTime"/>
      <bind jr:preload="uid" nodeset="/data/meta/instanceID" readonly="true()" type="string"/>
    </model>
  </h:head>
  <h:body>
    <input ref="/data/source">
      <setvalue event="xforms-value-changed" ref="/data/destination" value="now()"/>
    </input>
  </h:body>
</h:html>

Steps:

  1. Load the form above
  2. Update the source field
  3. Submit the form above and see that the destination field is filled in with the current time
  4. Edit the submission and submit again without changing the source field value
  5. Notice that the destination field date is updated

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions