Cht-core: Error when using `tel` type entry in a contact form in 2.14.0 and above

Created on 22 Feb 2018  路  6Comments  路  Source: medic/cht-core

When using tel type field in a contact form in my local test instance (2.14.0-beta.10) and another instance on 2.15.0, the form fails to open and throws this error:

inbox.js:3 TypeError: Cannot read property 'split' of undefined
inbox.js:3 Error loading contact form. Error: ["TypeError: Cannot read property 'split' of undefined"]

The same form is loading properly in ebpp-indonesia (2.13.1)
When I replace tel with text, the form loads fine.

Bug

All 6 comments

From my test the tel type works in 2.14.0-beta.10 as long as there is no relevant on it.

For instance, the following tel field without a relevant works:
<bind constraint="true()" jr:constraintMsg="jr:itext('/data/person/phone:jr:constraintMsg')" nodeset="/data/person/phone" type="tel" />

This tel field with a relevant does not work and throws the error mentioned by @binokaryg:
<bind constraint="true()" jr:constraintMsg="jr:itext('/data/person/phone:jr:constraintMsg')" nodeset="/data/person/phone" type="tel" relevant="true()"/>

Both of these work on 2.13.5.

Unminified error:

input node has no name
TypeError: Cannot read property 'split' of undefined
    at HTMLInputElement.<anonymous> (branch.js:69)
    at Function.each (jquery.js:362)
    at jQuery.fn.init.each (jquery.js:157)
    at Object.updateNodes (branch.js:38)
    at Object.update (branch.js:21)
    at Form.init (Form.js:200)
    at enketo.js:254
    at processQueue (angular.js:17051)
    at angular.js:17095
    at Scope.$digest (angular.js:18233)
Error loading form. Error: ["TypeError: Cannot read property 'split' of undefined"]
    at enketo.js:256
    at processQueue (angular.js:17051)
    at angular.js:17095
    at Scope.$digest (angular.js:18233)
    at angular.js:18462
    at completeOutstandingRequest (angular.js:6362)
    at angular.js:6642

Demo form:

<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa">
    <h:head>
        <h:title>phone - Demo Form</h:title>

        <model>
            <instance>
                <phone id="phone">
                    <my_phone/>
                    <meta>
                        <instanceID/>
                    </meta>
                </phone>
            </instance>
            <bind constraint="true()" jr:constraintMsg="constraint" nodeset="/phone/my_phone" type="tel" relevant="true()"/>
        </model>
    </h:head>

    <h:body>
        <input ref="/phone/my_phone">
            <label>Enter your phone number</label>
        </input>
    </h:body>
</h:html>

Merged and backported to 2.14.x

This works for me on 2.14.0-beta.13, moving to Ready. @binokaryg can you also confirm it works for you and share back here? We can reopen if needed.

Upgraded local test instance to 2.14.0-beta.14. Now the form havingtel type with relevant field loads properly. Thank you.

Was this page helpful?
0 / 5 - 0 ratings