Create a new string and use it.
IS_DATE() translates the string you send to it, as you can see in the
source code [1].
So, you need to create another string will be translated to your desired format.
Something like this:
db.product.expiration.requires = IS_DATE(format("Y-m-d"))
and in translation file, put:
"Y-m-d": "%Y-%m-%d"
This is not a bug. It's designed to work this way.
[1] https://github.com/web2py/web2py/blob/master/gluon/validators.py#L2229
On Mon, Nov 4, 2013 at 2:11 PM, Diogo Munaro <[email protected]> wrote:
> No, the problem is that the form get accepted only if the browser language
> is english.
>
> Otherwise, if the browser is in portuguese it's change the validation to
> DD-MM-YYYY, but I don't want
>
> I don't want T or internalizations
>
>
>
> 2013/11/4 Richard Vézina <[email protected]>
>>
>> Are you talking about the error message?
>>
>> This should work :
>>
>> IS_DATE(format=T('%Y-%m-%d'), error_message=T('Valid date of format :
>> YYYY-MM-DD'))
>>
>> Notice the T() above...
>>
>> Richard
>>
>>
>> On Mon, Nov 4, 2013 at 10:19 AM, Diogo Munaro <[email protected]>
>> wrote:
>>>
>>> Hi, I'm using web2py 2.7.2 and date fields on DAL are translating your
>>> validate.
>>>
>>> Example:
>>>
>>> I have in model:
>>>
>>> product = db.define_table('product',
>>> Field('expiration','date'))
>>>
>>> db.product.expiration.requires = IS_DATE(format('%Y-%m-%d'))
>>>
>>> T.force(None)
>>>
>>> When I insert a date like this: 2013-11-19
>>>
>>> If my browser is in english language:
>>>
>>> It's ok and insert in database
>>>
>>> If my browser is in brazilian portuguese language:
>>>
>>> The form returns a error like this: enter date as 28-08-1963
>>>
>>> How could I force the format AAAA-MM-DD?
>>>
>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.