Posted by
Tambet Matiisen on
URL: https://discuss.orbeon.com/Recommended-Way-To-Handle-Non-ISO-Date-Formats-tp4410775p4411384.html
It seems, that you are basically doing right thing, but I didn't
understand why you need all that constraint and default code in first
bind. In my opinion you just need 2 instances:
1) the first one is used for entering data. This is where data type is
date, to render the date control on input form.
2) the second one is used for sending data to external service. In this
instance the data type is string for the same element and you can
calculate it from the first instance using bind rule similar to the last
one of yours. You can copy other elements with calculate rule as well.
Actually, if your form has many fields and repeats, then having two
instances and copying data between them might complicate the process too
much. So you could also put the second field into the same instance and
enable it only during submission. The code could be something like this:
<xforms:instance>
<data>
...
<PersonalDetails>
<DateOfBirth>1976-05-12</DateOfBirth>
<DateOfBirth>05/12/1976</DateOfBirth>
</PersonalDetails>
...
</data>
</xforms:instance>
<xforms:instance id="control">
<data>
<submitting>false</submitting>
</data>
</xforms:instance>
<xforms:bind nodeset="PersonalDetails/DateOfBirth[1]" type="xforms:date"
relevant="not(boolean-from-string(instance('control')/submitting))"/>
<xforms:bind nodeset="PersonalDetails/DateOfBirth[2]"
type="xforms:string"
relevant="boolean-from-string(instance('control')/submitting)"
calculate="format-date(../DateOfBirth[1],
'[M01]/[D01]/[Y]')"/>
<xforms:submission action="..." ...>
<xforms:setvalue ref="instance('control')/submission" value="'true'"
events:event="xforms-submit"/>
<xforms:setvalue ref="instance('control')/submission" value="'false'"
events:event="xforms-submit-done"/>
<xforms:setvalue ref="instance('control')/submission" value="'false'"
events:event="xforms-submit-error"/>
</xforms:submission>
Tambet
On 23.02.2012 5:03, Kaex wrote:
> Never mind, I had a stray "xform-value-changed" listener from an earlier
> attempt.
>
> I remove that and everything works fine. I'm still interested in any better
> ways to accomplish this though.
>
> --
> View this message in context:
http://orbeon-forms-ops-users.24843.n4.nabble.com/Recommended-Way-To-Handle-Non-ISO-Date-Formats-tp4410775p4410826.html> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
--
You receive this message as a subscriber of the
[hidden email] mailing list.
To unsubscribe: mailto:
[hidden email]
For general help: mailto:
[hidden email]?subject=help
OW2 mailing lists service home page:
http://www.ow2.org/wws