Format input date type

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Format input date type

cvesters
Hi,

We are currently trying to apply some formatting to input elements.
So far we have succeeded in applying formatting for string and numbers by using the xxf:unformat and xxf:format attributes. Now we are trying to do the same for fields of the type date, but the date picker can not handle the formatted value.

We are aware that there is an option to select the formatting, but we really need to allow a custom formatting on a specific input element.

We are thinking of two solutions:
1. Make a call to Orbeon to unformat the value using the xxf:unformat attribute.
2. Add the unformatted value of the date. This value is currently not provided by Orbeon though.

What other options are there? And which one would be best?

Another problem we face is an input of type dateTime. Orbeon provides two seperate input fiels, one for the date and one for the time. What if we want to format the dateTime to mix the time and date?
This would be impossible as there are two separate fields.
Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

Alessandro  Vernet
Administrator

On Mon, Jun 29, 2015 at 3:38 AM, cvesters <[hidden email]> wrote:
Hi,

We are currently trying to apply some formatting to input elements.
So far we have succeeded in applying formatting for string and numbers by
using the xxf:unformat and xxf:format attributes. Now we are trying to do
the same for fields of the type date, but the date picker can not handle the
formatted value.

We are aware that there is an option to select the formatting, but we really
need to allow a custom formatting on a specific input element.

We are thinking of two solutions:
1. Make a call to Orbeon to unformat the value using the xxf:unformat
attribute.
2. Add the unformatted value of the date. This value is currently not
provided by Orbeon though.

What other options are there? And which one would be best?

Another problem we face is an input of type dateTime. Orbeon provides two
seperate input fiels, one for the date and one for the time. What if we want
to format the dateTime to mix the time and date?
This would be impossible as there are two separate fields.


--
View this message in context: http://discuss.orbeon.com/Format-input-date-type-tp4660150.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

cvesters
This post was updated on .
It is, just trying different channels.
Since I'm not getting a satisfying answer.
Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

cvesters
In reply to this post by cvesters
We really need to know if we can solve this easily.

Basically we have to following problem:
- Users can specify their own date format, which can be anything.
- Each date input can have it's own format

We want some way to make the datepicker compatible with the specified formats.
Several ideas exist:
- The datepicker should ask to unformat the date
- The unformatted value is added as a hidden element in the form

What are the possibilities? How can we do this?
Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

Erik Bruchez
Administrator
No problem using the forum vs. StackOverflow.

I think the answer to your immediate question "if we can solve this easily" is "no": it is not just a one-line change or a configuration change. And if "How can we do this?" means "can anybody at Orbeon provide the code to do it right now", I think the answer is "no" too because it is an enhancement which requires some thinking and then some implementation.

This said, we are very happy to work with you and guide you to introduce this change, but I just wanted to set the expectations.

The date picker is purely client-side, and is expected to send an ISO-like format to the server. So some JavaScript needs to be modified. Also, the client cannot run XPath at this time. So I am not sure xxf:unformat will work for this.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

cvesters
This post was updated on .
Thank you for the reply. I looked into it myself a bit and I didn't think it would be easy.
But perhaps I was missing something.

It would have been nice if we could call Orbeon from the datapicker and ask it to unformat the date using the xxf:unformat. This way we keep a clear separation from client/server.

Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

cvesters
Currently our idea is to use a hidden value containing the unformatted value.
Orbeon will need to be extended to send the unformatted value along with the formatted value for this.

The datepicker will take the value of the unformatted value to pick the right date, and write the selected date back to it. Then an event needs to be sent so Orbeon can take the unformatted value and format it.

Do you consider this a viable option? What are the potential problems? Any alternatives or useful remarks?

Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

Erik Bruchez
Administrator
> It would have been nice if we could call Orbeon from the datapicker and ask it to unformat the date using the xxf:unformat. This way we keep a clear separation from client/server.

Yes, but since Orbeon Forms currently does more on the server than on the client, it's not (yet) possible easily.

> Currently our idea is to use a hidden value containing the unformatted value.
> Orbeon will need to be extended to send the unformatted value along with the formatted value for this.
>
> The datepicker will take the value of the unformatted value to pick the right date, and write the selected > date back to it. Then an event needs to be sent so Orbeon can take the unformatted value and format it.
>
> Do you consider this a viable option? What are the potential problems? Any alternatives or useful remarks?

I am trying to think about a slightly different solution. A few questions though:

- Which version of Orbeon Forms are you using?
- Are you using Form Builder/Form Runner?
- Do you have many date controls in a given form?
- Do you need this for date/time as well?

I am trying to see whether writing a custom XBL component to handle dates would work. Something like the `fr:number` control:

    https://github.com/orbeon/orbeon-forms/blob/master/src/resources-packaged/xbl/orbeon/number/number.xbl

In short, instead of modifying the existing date control, which is built-in, write a "fancy-date" component which handles the special formatting you are looking for.

Orbeon Forms 4.10 supports custom controls mapping to appearances:

    http://blog.orbeon.com/2015/06/how-new-form-builder-appearance.html

This means that Form Builder can still see this as a date, but the date would have a special appearance which you could pick in Form Builder (it can also be directly available in the toolbox). It would take an extra attribute to specify the format, handled by the component. The component can also have some JavaScript to handle formatting/unformatting and showing the date picker. But it would do this independently from the "standard" date picker.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

cvesters
We are using Orbeon 4.4.1.
We don't use the form builder, but the form runner.

The amount of date controls can vary as it are not our forms, but our customers.
It is requested to have the same thing for date/time as well.
Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

Erik Bruchez
Administrator
Ok, in that case it is still possible to go the component route, but you would directly use the custom control instead of a regular input field.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

cvesters
Just to make sure I understand correctly. The advice is to create a custom calendar component that can handle formatting?

In what extend can I base the work on the current existing calendar?
Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

Erik Bruchez
Administrator
To be fair, I am a bit torn between the two possibilities:

- modifying the existing built-in date control
- creating a custom control

The built-in implementation is pretty old and a bit too rigid. A lot is coded in xforms.js. [1] The calendar proper is handled in calendar.coffee. [2] The fancy date and time parsing is in xforms.js. [3]

It would be ideal to be able to reuse some code, yes. It's hard to say exactly how or what without starting the work.

-Erik

[1] https://github.com/orbeon/orbeon-forms/blob/master/src/resources-packaged/ops/javascript/xforms.js
[2] https://github.com/orbeon/orbeon-forms/blob/master/src/resources-packaged/ops/javascript/orbeon/xforms/control/Calendar.coffee
[3] https://github.com/orbeon/orbeon-forms/blob/master/src/resources-packaged/ops/javascript/xforms.js#L516
Reply | Threaded
Open this post in threaded view
|

Re: Format input date type

Erik Bruchez
Administrator
Some further thoughts in this RFE:

    https://github.com/orbeon/orbeon-forms/issues/2295

I think we would like, at some point, to solve this by having the built-in date/time/dateTime controls written in XBL in the first place. This would make it much easier to make changes to these controls.

-Erik