Formula : 4 simple issues with validation

edited November 6 in XML Technologies

Hi guys,

I have uncovered 4 bugs around validation in Formula that I would love to get fixed so that the schema enforcing web xml editor I am building becomes commercially viable. Then I can arrange to pay to use Formula.

Each issue is present and visible in the simple example I have attached

This form keeps a list of invalid fields in an xml island. This does work. But there are 4 issues that are likely easy to solve by Simon Gigsen.

1. The form does not do an initial pass to validate fields when it first loads, so although fields are red, no xforms-invalid events fire

     - Once a new element is added or a trigger is pressed to change the relevancy the xforms-invalid events begin firing correctly.

2. Related to 1 and a nice to have, firing <revalidate model="model_0"/> does nothing. I think it should propagate through the model and fire xform-invalids wherever there is invalid data.

3. As you can see in the below image, when in a sequence, should the first element in the sequence be invalid the form will paint all the following elements in the sequence row as if they were invalid even when they are not.

4.Strangely I can write to all attributes of a newly added invalids/field node except the @message attribute! Cannot work around this one!

Screenshot-2017-11-3 XForms Engine (Formula).png

Here is the XForm


<?xml version="1.0" encoding="utf-8" ?>
<h:html xmlns:h="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xj="tempuri.org" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <h:head>
    <model id="model_0">
      <schema>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
          <xs:element name="structure-test">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="c-c-s">
                  <xs:complexType>
                    <xs:choice maxOccurs="2">
                      <xs:choice maxOccurs="2">
                        <xs:element name="A"/>
                        <xs:element name="B"/>
                        <xs:sequence maxOccurs="2">
                          <xs:element name="C"/>
                          <xs:element name="D"/>
                        </xs:sequence>
                      </xs:choice>
                      <xs:sequence>
                        <xs:element name="E"/>
                      </xs:sequence>
                    </xs:choice>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:schema>
      </schema>
      <instance id="instance_0">
        <structure-test xmlns="" xmlns:xj="tempuri.org">
          <c-c-s>
            <A xj:choice="1010">1</A>
            <B xj:choice="1010">42</B>
            <C xj:index="10" xj:choice="1010"></C>
            <D xj:index="10" xj:choice="1010">512</D>
            <C xj:index="20" xj:choice="1010"></C>
            <D xj:index="20" xj:choice="1010">514</D>
            <E xj:choice="10">7</E>
          </c-c-s>
        </structure-test>
      </instance>
      <instance id="ui">
        <ui xmlns="">
          <choices>
            <choicelot group="repeat_19">
              <choice index="10" type="A|B|C..">
                <choice index="1010" type="C.."/>
              </choice>
            </choicelot>
          </choices>
        
          <tpl>
            <atts xj:index="" />
            <choice index="0" type="" />
            <list />
            <error />
            <field name="" repeat="" index="0" choice="0" message=""/>
          </tpl>
         
          <state>
            <invalids></invalids>
            <errors></errors>
            <repeatid></repeatid>
            <iterator>0</iterator>
          </state>
        </ui>
      </instance>
      <instance id="template_0">
        <structure-test xmlns="">
          <c-c-s>
            <A xj:choice="0"/>
            <B xj:choice="0" />
            <C xj:index="0" xj:choice="0" />
            <D xj:index="0" xj:choice="0" />
            <E xj:choice="0" />
          </c-c-s>
        </structure-test>
      </instance>
      <bind id="bind_71" nodeset="c-c-s" minOccurs="1" maxOccurs="1">
        <bind id="bind_72" nodeset="A|B|C|E" minOccurs="1" maxOccurs="2">
          <bind id="bind_73" nodeset="self::A|self::B|self::C" minOccurs="1" maxOccurs="2">
            <bind id="bind_74" type="xs:decimal" nodeset="self::A" minOccurs="1" maxOccurs="1" relevant="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(current()/@xj:choice, @index)][@type='A|B|C..']/choice[@index = current()/@xj:choice]/@type='A'" />
            <bind id="bind_75" type="xs:decimal" nodeset="self::B" minOccurs="1" maxOccurs="1" relevant="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(current()/@xj:choice, @index)][@type='A|B|C..']/choice[@index = current()/@xj:choice]/@type='B'" />
            <bind id="bind_77" nodeset="self::C" minOccurs="1" maxOccurs="2" relevant="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(current()/@xj:choice, @index)][@type='A|B|C..']/choice[@index = current()/@xj:choice]/@type='C..'">
              <bind id="bind_78" type="xs:int" nodeset="self::C" minOccurs="1" maxOccurs="1" />
              <bind id="bind_79" type="xs:int" nodeset="following-sibling::D[@xj:index = current()/@xj:index]" minOccurs="1" maxOccurs="1" relevant="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(current()/@xj:choice, @index)][@type='A|B|C..']/choice[@index = current()/@xj:choice]/@type='C..'" />
            </bind>
          </bind>
          <bind id="bind_80" type="xs:int" nodeset="self::E" minOccurs="1" maxOccurs="1" relevant="instance('ui')/choices/choicelot[@group='repeat_19']/choice[@index = current()/@xj:choice]/@type='E'"/>
        </bind>
      </bind>


      <submission id="view" method="post" ref="instance('instance_0')" includenamespaceprefixes="#default" omit-xml-declaration="true" />
      <submission id="viewall" method="post" ref="instance('instance_0')" relevant="false" validate="false" />
    </model>
  </h:head>
  <h:body>
    <group class="toolbar">
      <group class="formbuttons">
        <submit id="submit_0" submission="view">
          <label id="label_0">View Final XML</label>
        </submit>
        <submit id="submit_1" submission="viewall">
          <label id="label_1">View All XML</label>
        </submit>
        <trigger>
          <label>Check Valid</label>
          <action><!-- Does nothing -->
            <revalidate model="model_0"/>
          </action>
        </trigger>
      </group>
      <group class="status-report">
        <group appearance="compact">
          <label>Doc Status:</label>
          <group id="valid" ref="self::node()[count(instance('ui')/state/invalids/field) = 0]">
            <h:i style="color:green" class="fa fa-check"> OK</h:i>
          </group>
          <group id="invalid" ref="self::node()[count(instance('ui')/state/invalids/field) &gt; 0]">
            <h:i style="color:red" class="fa fa-times">
              <output class="reason" value="concat(count(instance('ui')/state/invalids/field), ' Validation Error')"/><group class="reason" ref="self::node()[count(instance('ui')/state/invalids/field) &gt; 1]">s</group>
            </h:i>
          </group>
        </group>
      </group>
    </group>
    <group class="document-element" bind="bind_71">
      <group class="xforms-element block" appearance="full">
        <label class="title">
          4 validation related issue examples<h:hr/>
          <h:ol>
            <h:li>1. Validation does not run on model inital load - but does once an action is performed.</h:li>
            <h:li>2. Check Valid toolbar button does not cause validation to run.</h:li>
            <h:li>3. When in a repeated sequence the invalid status of the first item (red outline) is copied onto the following items even if they are valid.</h:li>
            <h:li>4. Cannot write to the @message attribute on the newly added field. </h:li>
          </h:ol>
        </label>
        <repeat bind="bind_72" id="repeat_19" appearance="full" class="xforms-choice min0 max-sm">
          <group id="cc0" ref="self::node()[count(preceding-sibling::*[name() = name(current())][starts-with(@xj:choice, instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(current()/@xj:choice, @index)]/@index)]) = 0]" class="firstOfChc triggers choices">
            <action ev:event="choice-change">
              <delete ref="instance('ui')/state/invalids/field[starts-with(@repeat,'19')]"/>
            </action>
            <trigger class="choiceBtn" appearance="minimal" ref="self::node()[instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@type != 'A|B|C..']">
              <label>A..</label>
              <action if="not(../A[starts-with(@xj:choice, context()/@xj:choice)])">
                <insert origin="instance('template_0')/c-c-s/A" context="context()" nodeset="context()" position="before" />
                <insert origin="instance('ui')/choice" context="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]" nodeset="choice" position="after" />
                <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(current()/@xj:choice, @index]/choice[last()]/@index" value="concat(instance('ui')/choices/choicelot[@group='repeat_19']/choice[last()]/@index, 10)"/>
                <setvalue ref="../A[@xj:choice = 0]/@xj:choice" value="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index]/choice[last()]/@index" />
                <dispatch ev:event="DOMActivate" name="choice-change" targetid="cc0"/>
                <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(current()/@xj:choice, @index]/choice[last()]/@type" value="'A'"/>
              </action>
              <dispatch ev:event="DOMActivate" name="choice-change" targetid="cc0"/>
              <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@type" value="'A|B|C..'" />
            </trigger>
            <trigger class="choiceBtn" appearance="minimal" ref="self::node()[instance('ui')/choices/choicelot[@group = 'repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@type != 'E']">
              <label>E</label>
              <action if="not(../E[starts-with(context()/@xj:choice, @xj:choice)])">
                <insert origin="instance('template_0')/c-c-s/E" context="context()" nodeset="(A|B|C|D)[starts-with(@xj:choice, instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@index)]" position="after"/>
                <setvalue ref="../E[@xj:choice = 0]/@xj:choice" value="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@index"/>;
              </action>
              <dispatch ev:event="DOMActivate" name="choice-change" targetid="cc0"/>
              <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@type" value="'E'" />
            </trigger>
            <group class="choice-append triggers">
              <trigger class="fa fa-plus-circle addBtn" appearance="minimal" ref="self::node()[instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)][@type = 'A|B|C..'][count(choice) &lt; 3]]">
                <label> A</label>
                <insert origin="instance('template_0')/c-c-s/A" context="context()/.." nodeset="(A|B|C|D)[starts-with(@xj:choice, instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@index)]" position="after" />
                <setvalue ref="../A[@xj:choice = 0]/@xj:choice" value="max(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice/@index) + 10" />
                <insert origin="instance('ui')/tpl/choice" context="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]" nodeset="choice" position="after" />
                <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/descendant-or-self::choice[@index = 0]/@index" value="max(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice/@index) + 10"/>
                <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/descendant-or-self::choice[@type = '']/@type" value="'A'"/>
              </trigger>
              <trigger class="fa fa-plus-circle addBtn" appearance="minimal" ref="self::node()[instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)][@type = 'A|B|C..'][count(choice) &lt; 3]]">
                <label> B</label>
                <insert origin="instance('template_0')/c-c-s/B" context="context()/.." nodeset="(A|B|C|D)[starts-with(@xj:choice, instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@index)]" position="after" />
                <setvalue ref="../B[@xj:choice = 0]/@xj:choice" value="max(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice/@index) + 10" />
                <insert origin="instance('ui')/tpl/choice" context="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]" nodeset="choice" position="after" />
                <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/descendant-or-self::choice[@index = 0]/@index" value="max(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice/@index) + 10"/>
                <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/descendant-or-self::choice[@type = '']/@type" value="'B'"/>
              </trigger>
              <trigger class="fa fa-plus-circle addBtn" appearance="minimal" ref="self::node()[instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)][@type = 'A|B|C..'][count(choice) &lt; 3]]">
                <label> C..</label>
                <insert origin="instance('template_0')/c-c-s/C|instance('template_0')/c-c-s/D" context="context()/.." nodeset="(A|B|C|D)[starts-with(@xj:choice, instance('ui')/choices/choicelot['repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@index)]" position="after" />
                <insert origin="instance('ui')/tpl/choice" context="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]" nodeset="choice" position="after" />
                <setvalue ref="../C[@xj:choice = 0]/@xj:choice" value="if(count(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice) = 0, concat(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@index, 10), max(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice/@index) + 10)" />
                <setvalue ref="../D[@xj:choice = 0]/@xj:choice" value="if(count(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice) = 0, concat(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@index, 10), max(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice/@index) + 10)" />
                <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/descendant::choice[@index=0]/@type" value="'C..'"/>
                <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/descendant::choice[@index=0]/@index" value="if(count(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice) = 0, concat(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@index, 10), max(instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice/@index) + 10)"/>
                <setvalue ref="../C[@xj:index = 0]/@xj:index" value="concat(context()/following-sibling::E[1]/@xj:index,translate(substring(max(../../C[starts-with(@xj:index, context()/following-sibling::E[1]/@xj:index)]/@xj:index), string-length(context()/following-sibling::E[1]/@xj:index) + 1) div 10 + 1, '0','1'), '0')"/>
                <setvalue ref="../D[@xj:index = 0]/@xj:index" value="concat(context()/following-sibling::E[1]/@xj:index,translate(substring(max(../../D[starts-with(@xj:index, context()/following-sibling::E[1]/@xj:index)]/@xj:index), string-length(context()/following-sibling::E[1]/@xj:index) + 1) div 10 + 1, '0','1'), '0')"/>
              </trigger>
            </group>
            <group class="choice-delete triggers triggers-end">
              <trigger class="fa fa-times-circle deleteBtn" appearance="minimal">
                <delete ref="../*[starts-with(@xj:choice, instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@index)]" />
                <delete ref="instance('ui')/choices/choicelot[@group='repeat_19']/choice[@index = instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/@index]" />
              </trigger>
            </group>
          </group>
          <group id="group_17" bind="bind_73" appearance="full" class="xforms-choice min0 max-sm">
            <group id="cc1" ref="self::node()[count(preceding-sibling::*[local-name() = local-name(current())][@xj:choice = current()/@xj:choice]) = 0]" class="firstOfChc triggers repeated">
              <action ev:event="choice-change">
                <delete ref="instance('ui')/state/invalids/field[starts-with(@repeat,'19_17')][starts-with(@choice, context()/@xj:choice)]"/>
              </action>
              <group class="choices">
                <trigger class="choiceBtn" appearance="minimal" ref="self::node()[not(self::A)]">
                  <label>A</label>
                  <action if="not(../A[starts-with(context()/@xj:choice, @xj:choice)])">
                    <insert origin="instance('template_0')/c-c-s/A" context="context()/.." nodeset="(A|B|C|D)[starts-with(@xj:choice, instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice[starts-with(context()/@xj:choice, @index)]/@index)]" position="after" at="1"/>
                    <setvalue ref="../A[@xj:choice = 0]/@xj:choice" value="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice[starts-with(context()/@xj:choice, @index)]/@index" />
                  </action>
                  <dispatch ev:event="DOMActivate" name="choice-change" targetid="cc1"/>
                  <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice[starts-with(context()/@xj:choice, @index)]/@type" value="'A'" />
                </trigger>
                <trigger class="choiceBtn" appearance="minimal" ref="self::node()[not(self::B)]">
                  <label>B</label>
                  <action if="not(../B[starts-with(context()/@xj:choice, @xj:choice)])">
                    <insert origin="instance('template_0')/c-c-s/B" context="context()/.." nodeset="(A|B|C|D)[starts-with(@xj:choice, instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice[starts-with(context()/@xj:choice, @index)]/@index)]" position="after" />
                    <setvalue ref="../B[@xj:choice = 0]/@xj:choice" value="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice[starts-with(context()/@xj:choice, @index)]/@index" />
                  </action>
                  <dispatch ev:event="DOMActivate" name="choice-change" targetid="cc1"/>
                  <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice[starts-with(context()/@xj:choice, @index)]/@type" value="'B'" />
                </trigger>
                <trigger class="choiceBtn" appearance="minimal" ref="self::node()[not(self::C)]">
                  <label>C..</label>
                  <action if="not((../C)[starts-with(@xj:choice, context()/@xj:choice)])" xj:annotation="graceful accept of incomplete content">
                    <insert origin="instance('template_0')/c-c-s/C|instance('template_0')/c-c-s/D" context="context()/.." nodeset="(A|B|C|D)[starts-with(context()/@xj:choice, @xj:choice)]" position="after" />
                    <setvalue ref="../C[@xj:index = 0]/@xj:index" value="concat(context()/following-sibling::E[1]/@xj:index,translate(substring(max(../../C[starts-with(@xj:index, context()/following-sibling::E[1]/@xj:index)]/@xj:index), string-length(context()/following-sibling::E[1]/@xj:index) + 1) div 10 + 1, '0','1'), '0')"/>
                    <setvalue ref="../D[@xj:index = 0]/@xj:index" value="concat(context()/following-sibling::E[1]/@xj:index,translate(substring(max(../../D[starts-with(@xj:index, context()/following-sibling::E[1]/@xj:index)]/@xj:index), string-length(context()/following-sibling::E[1]/@xj:index) + 1) div 10 + 1, '0','1'), '0')"/>
                    <setvalue ref="../C[@xj:choice = 0]/@xj:choice" value="context()/@xj:choice" />
                    <setvalue ref="../D[@xj:choice = 0]/@xj:choice" value="context()/@xj:choice" />
                  </action>
                  <dispatch ev:event="DOMActivate" name="choice-change" targetid="cc1"/>
                  <setvalue ref="instance('ui')/choices/choicelot[@group='repeat_19']/choice[starts-with(context()/@xj:choice, @index)]/choice[starts-with(context()/@xj:choice, @index)]/@type" value="'C..'" />
                </trigger>
              </group>
              <group ref="self::node()[not(self::C) or count(preceding-sibling::C[@xj:choice = current()/@xj:choice]) = 0]" class="triggers-end sequence-append triggers">
                <trigger class="fa fa-plus-circle addBtn" appearance="minimal" ref="self::node()[count(../C[@xj:choice = context()/@xj:choice]) &lt; 3][instance('ui')/choices/choicelot[@group='repeat_19']//choice[@index = context()/@xj:choice]/@type = 'C..']">
                  <label> C..</label>
                  <insert origin="instance('template_0')/c-c-s/C|instance('template_0')/c-c-s/D" context="context()/.." nodeset="(C|D)[starts-with(@xj:index, context()/following-sibling::E[1]/@xj:index))][@xj:choice = context()/@xj:choice]" position="after" />
                  <setvalue ref="../C[@xj:index = 0]/@xj:index" value="concat(context()/following-sibling::E[1]/@xj:index,translate(substring(max(../../C[starts-with(@xj:index, context()/following-sibling::E[1]/@xj:index)]/@xj:index), string-length(context()/following-sibling::E[1]/@xj:index) + 1) div 10 + 1, '0','1'), '0')"/>
                  <setvalue ref="../D[@xj:index = 0]/@xj:index" value="concat(context()/following-sibling::E[1]/@xj:index,translate(substring(max(../../D[starts-with(@xj:index, context()/following-sibling::E[1]/@xj:index)]/@xj:index), string-length(context()/following-sibling::E[1]/@xj:index) + 1) div 10 + 1, '0','1'), '0')"/>
                  <setvalue ref="../C[@xj:choice = 0]/@xj:choice" value="if(../preceding-sibling::*[1]/@xj:choice, ../preceding-sibling::*[1]/@xj:choice, 1)"/>
                  <setvalue ref="../D[@xj:choice = 0]/@xj:choice" value="if(../preceding-sibling::*[1]/@xj:choice, ../preceding-sibling::*[1]/@xj:choice, 1)"/>
                </trigger>
              </group>
              <group class="choice-delete triggers triggers-end">
                <trigger class="fa fa-times-circle deleteBtn" appearance="minimal">
                  <delete ref="../*[starts-with(@xj:choice, instance('ui')/choices/choicelot[@group='repeat_19']/choice/choice[starts-with(context()/@xj:choice, @index)]/@index)]" />
                  <delete ref="instance('ui')/choices/choicelot[@group='repeat_19']/choice/choice[@index = instance('ui')/choices/choicelot[@group='repeat_19']/choice/choice[starts-with(context()/@xj:choice, @index)]/@index]" />
                </trigger>
              </group>
            </group>
            <range bind="bind_74" class="el-A input-md" start="1" end="1000" step="1">
              <label>A</label>
              <action ev:event="xforms-invalid" if="count(instance('ui')/state/invalids/field[@name = 'A'][@repeat = '19_17'][@choice = context()/@xj:choice]) = 0">
                <insert origin="instance('ui')/tpl/field" context="instance('ui')/state/invalids" nodeset="*[1]" position="before"/>
                <setvalue ref="instance('ui')/state/invalids/field[1]/@name" value="'A'"/>
                <setvalue ref="instance('ui')/state/invalids/field[1]/@repeat" value="'19_17'"/>
                <setvalue ref="instance('ui')/state/invalids/field[1]/@choice" value="context()/@xj:choice"/>
                <!--<setvalue ref="instance('ui')/state/invalids/field[1]/@message" value="'Must be a Decimal value.'"/>-->
              </action>
              <action ev:event="xforms-valid">
                <delete ref="instance('ui')/state/invalids/field[@name = 'A'][@repeat = '19_17'][@choice = context()/@xj:choice]"/>
              </action>
            </range>
            <input bind="bind_75" class="el-B input-md" start="1" end="1000" step="2" incremental="true">
              <label>B</label>
              <action ev:event="xforms-invalid" if="count(instance('ui')/state/invalids/field[@name = 'B'][@repeat = '19_17'][@choice = context()/@xj:choice]) = 0">
                <insert origin="instance('ui')/tpl/field" context="instance('ui')/state/invalids" nodeset="*[1]" position="before"/>
                <setvalue ref="instance('ui')/state/invalids/field[1]/@name" value="'B'"/>
                <setvalue ref="instance('ui')/state/invalids/field[1]/@repeat" value="'19_17'"/>
                <setvalue ref="instance('ui')/state/invalids/field[1]/@choice" value="context()/@xj:choice"/>
                <!--<setvalue ref="instance('ui')/state/invalids/field[1]/@message" value="'Must be a Decimal value.'"/>-->
              </action>
              <action ev:event="xforms-valid">
                <delete ref="instance('ui')/state/invalids/field[@name = 'B'][starts-with(@repeat,'19_17')][@choice = context()/@xj:choice]"/>
              </action>
            </input>
            <repeat bind="bind_77" id="repeat_20" appearance="full" class="xforms-sequence">
              <input class="el-C input-sm" bind="bind_78">
                <label>C</label>
                <action ev:event="xforms-invalid" if="count(instance('ui')/state/invalids/field[@name = 'C'][@repeat = '19_17'][@choice = context()/@xj:choice][@index = context()/@xj:index]) = 0">
                  <insert origin="instance('ui')/tpl/field" context="instance('ui')/state/invalids" nodeset="*[1]" position="before"/>
                  <setvalue ref="instance('ui')/state/invalids/field[1]/@name" value="'C'"/>
                  <setvalue ref="instance('ui')/state/invalids/field[1]/@repeat" value="'19_17'"/>
                  <setvalue ref="instance('ui')/state/invalids/field[1]/@choice" value="context()/@xj:choice"/>
                  <setvalue ref="instance('ui')/state/invalids/field[1]/@index" value="context()/@xj:index"/>
                  <!--<setvalue ref="instance('ui')/state/invalids/field[1]/@message" value="Must be an Integer value."/>-->
                </action>
                <action ev:event="xforms-valid">
                  <delete ref="instance('ui')/state/invalids/field[@name = 'C'][@repeat = '19_17'][@choice = context()/@xj:choice][@index = context()/@xj:index]"/>
                </action>
              </input>
              <input class="el-D input-sm" bind="bind_79">
                <label>D</label>
                <action ev:event="xforms-invalid" if="count(instance('ui')/state/invalids/field[@name = 'D'][@repeat = '19_17'][@choice = context()/@xj:choice][@index = context()/@xj:index]) = 0">
                  <insert origin="instance('ui')/tpl/field" context="instance('ui')/state/invalids" nodeset="*[1]" position="before"/>
                  <setvalue ref="instance('ui')/state/invalids/field[1]/@name" value="'D'"/>
                  <setvalue ref="instance('ui')/state/invalids/field[1]/@repeat" value="'19_17'"/>
                  <setvalue ref="instance('ui')/state/invalids/field[1]/@choice" value="context()/@xj:choice"/>
                  <setvalue ref="instance('ui')/state/invalids/field[1]/@index" value="context()/@xj:index"/>
                  <!--<setvalue ref="instance('ui')/state/invalids/field[1]/@message" value="'Must be an Integer value.'"/>-->
                  <!--<message level="ephemeral">@message = '<output ref="instance('ui')/state/invalids/field[1]/@message"/>;'</message>-->
                </action>
                <action ev:event="xforms-valid">
                  <delete ref="instance('ui')/state/invalids/field[@name = 'D'][@repeat = '19_17'][@choice = context()/@xj:choice][@index = context()/@xj:index]"/>
                </action>
              </input>
              <group class="sequence-delete triggers triggers-end">
                <trigger class="fa fa-times-circle deleteBtn" appearance="minimal" ref="self::node()[count(context()/../C[starts-with(@xj:index, preceding-sibling::A/@xj:index)]) &gt; 1]">
                  <delete ref="instance('ui')/state/invalids/field[@repeat = '19_17'][@choice = context()/@xj:choice][@index = context()/@xj:index]"/>
                  <delete ref="../*[@xj:index = context()/@xj:index]" />
                </trigger>
              </group>
            </repeat>
          </group>
          <group>
            <input bind="bind_80" class="el-E input-md">
              <label>E</label>
             
              <action ev:event="xforms-invalid" if="count(instance('ui')/state/invalids/field[@name = 'E'][@repeat = '19'][@choice = context()/@xj:choice]) = 0">
                <insert origin="instance('ui')/tpl/field" context="instance('ui')/state/invalids" nodeset="*[1]" position="before"/>
                <setvalue ref="instance('ui')/state/invalids/field[1]/@name" value="'E'"/>
                <setvalue ref="instance('ui')/state/invalids/field[1]/@repeat" value="'19'"/>
                <setvalue ref="instance('ui')/state/invalids/field[1]/@choice" value="context()/@xj:choice"/>
                 <!--<setvalue ref="instance('ui')/state/invalids/field[1]/@message" value="'Must be an Integer value.'"/>-->
              </action> 
              <action ev:event="xforms-valid" if="count(instance('ui')/state/invalids/field[@name = 'E'][@repeat = '19'][@choice = context()/@xj:choice]) > 0">
                <delete ref="instance('ui')/state/invalids/field[@name = 'E'][@repeat = '19'][@choice = context()/@xj:choice]"/>
              </action>
            </input>
          </group>
        </repeat>
      </group>
    </group>
  </h:body>
</h:html>

Please respond. These are like the tail end of issues and Formula will be most complete when they are fixed I am sure.

Thankyou,

Joe Warwick

Comments

  • edited November 6

    Hello again!

    OK good news I did manage to solve no's 1,2 and 3.

    For 1 & 2 I did this in the JS initialization code:

    form.addEventListener(function(event) {

                    switch (event.getName()) {

                        case "xforms-ready":

                            setTimeout(function () {

                                form.getModel('model_0').refresh();

                            }, 200);

                            break;

    3 was not an xforms issue, just css.

    4 still stands though.

    Thanks,

    Joe

Sign In or Register to comment.