Date format and number length.

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

Date format and number length.

inigo10rodri
Hi,

I am trying to put the input date in different formats according to the
locale selected by the user. It is possible to pass in some way the language
of the page to put it in the corresponding format depending on the selected
locale? with some property, XPATH formulas, adding external validations,
etc.

I have used the next property (<property as = "xs: string" name =
"oxf.xforms.format.input.date" value = "[D01] / [M01] / [Y0001]" />) and I
only get the format of the input as ([D01] / [M01] / [Y0001]). Is  any other
way to show the input in one way or another according to the selected
locale?

I have also been trying using XPATH formulas to validate that when entering
a phone number it can only have 9 characters. I´ve not been able to put that
condition because I don´t see the option to put a maximun length to a number
with XPATH formulas. Is there any other way to do it?
I need it to be a number, to add a prefix depending on the country you are.

I hope you can help me, thank you very much.

Regards,
Iñigo.

--
Sent from: http://discuss.orbeon.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].
Reply | Threaded
Open this post in threaded view
|

Re: Date format and number length.

Alessandro  Vernet
Administrator
Hi Iñigo,

Regarding having a different date format depending on the language, this is
covered by RFE #1152 (see link below), and I added a +1 from you. We are
working on a new date control, so once done, there is a better chance we can
address this as well.

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

To check you have a 9 digits in a field, I wouldn't try to mark the field as
a number, but instead just use the following validation expression:
`matches(., '^[0-9]{9}$')`. You'll let me know if this works for you.

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.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].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Date format and number length.

inigo10rodri
Hi Alessandro,

The validation of the number I´ve already solved.

So, is not possible to configure this control in some way to change the
format?

Thanks for your reply.

Iñigo.



--
Sent from: http://discuss.orbeon.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].
Reply | Threaded
Open this post in threaded view
|

Re: Date format and number length.

Alessandro  Vernet
Administrator
Hi Iñigo,

I'm afraid that we would really need to implement #1152 for you to be able
to change the format based on the language, or some other criterium. Until
this, I am not really seeing any workaround. And again, I'm hoping that
we'll get a chance to implement it after the date control has been redone.
Will you be able to be able to use your forms in the meantime, or is this a
blocker for your project?

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.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].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Date format and number length.

inigo10rodri
Hi Alessandro,

We can continue with the proyect until you redo the control date, but it´s
possible to edit the *xforms.js* and add a function or edit some function to
configure this?

Do you know how long it will take you more or less?

Thanks,
Iñigo





--
Sent from: http://discuss.orbeon.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].
Reply | Threaded
Open this post in threaded view
|

Re: Date format and number length.

Alessandro  Vernet
Administrator
Hi Iñigo,

Hacking `xforms.js` might provide you with a reasonable workaround, waiting
for #1152 to be implemented. Somewhere in there, you will see:

this.formatInputDate = new ORBEON.util.Property("format.input.date",
"[M]/[D]/[Y]");

You can see how `Property` is defined just a little bit earlier in the code:
its instances essentially just provide a `.get()` that return the value of
the property. So, there, you could change the code to set
`this.formatInputDate` to your own object with a `.get()` that returns a
different format depending the current language, completely ignoring the
value of the `oxf.xforms.format.input.date` property. And you can find the
current language through the `lang` attribute on the root `html` element.

You'll let me know if this works for you.

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.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].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Date format and number length.

inigo10rodri
Hi Alessandro,

I add the following in xforms.js and I can´t do anything in the form builder
all the js breaks down.

DateFormat: function (){

                        var DateFormat = function(name,formatedDate){
                                if(document.documentElement.lang == "eu"){
                                       
                                        formatedDate="[Y0001]/[M01]/[D01]";
                                        this.formatedDate=formatedDate;
                                        this.name=name;
                                       
                                }else{
                                       
                                        this.formatedDate=formatedDate;
                                        this.name=name;
                                       
                                }
                        };
                       
                        DateFormat.prototype.get = function(){
                               
                                return _.isUndefined(opsXFormsProperties) ||
_.isUndefined(opsXFormsProperties[this.name])
                                ? this.formatedDate : opsXFormsProperties[this.name];
                               
                        };
                        return DateFormat;
                               
                }(),

And this:

this.formatInputDate                  = new
ORBEON.util.DateFormat("format.input.date","[D01]/[M01]/[Y0001]");

Hope you can help me, thanks.

Iñigo.

--
Sent from: http://discuss.orbeon.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].
Reply | Threaded
Open this post in threaded view
|

Re: Date format and number length.

Alessandro  Vernet
Administrator
Hi Iñigo,

I am not that I can help much: if you open the Dev Tools, say on Chrome, are
you seeing any error on the console when you load the page? If so, I'd
recommend you debug the code where the error is happening. You'll let me
know if this helps.

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.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].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Date format and number length.

inigo10rodri
Hi Alex,

I do not have any errors at this time, but it did not take me the js that
additional. The format date that is set by default remains.

I tried it in all possible ways and I can´t control the date format.

Maybe it could be better to wait until you redo the date control? Do you
know if someone has got it?

Thanks,
Iñigo.

--
Sent from: http://discuss.orbeon.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].
Reply | Threaded
Open this post in threaded view
|

Re: Date format and number length.

Alessandro  Vernet
Administrator
Hi Iñigo,

If you don't have have any errors showing in the Dev Tools console, I would recommend you debug your code with the Dev Tools JavaScript debugger: is your code even showing in the debugger (if not, it could be a deployment problem), if so is it running, if so you should be able to see where it goes wrong with the debugger. You'll let us know how how it goes.

Alex

On Thu, Aug 9, 2018 at 8:31 PM inigo10rodri <[hidden email]> wrote:
Hi Alex,

I do not have any errors at this time, but it did not take me the js that
additional. The format date that is set by default remains.

I tried it in all possible ways and I can´t control the date format.

Maybe it could be better to wait until you redo the date control? Do you
know if someone has got it?

Thanks,
Iñigo.

--
Sent from: http://discuss.orbeon.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