# |
Mar 8th 2018, 16:27 |
ricksaccous |
wait do commas in european prices work like cents? |
# |
Mar 8th 2018, 16:25 |
ricksaccous |
lol |
# |
Mar 8th 2018, 16:25 |
ricksaccous |
int it up dyud |
# |
Mar 8th 2018, 16:25 |
jojomartius |
stupid shit |
# |
Mar 8th 2018, 16:25 |
jojomartius |
but my friend here is comming with a english IE, typing in german numbers and because IE is not able to send floats out and mysql is not accepting comma seperated decimals i loose information :( |
# |
Mar 8th 2018, 16:25 |
lorenzo |
you could have a select for “use comma as separator, or use dot as separator” and use that as the hint |
# |
Mar 8th 2018, 16:24 |
lorenzo |
it’s difficult to guess |
# |
Mar 8th 2018, 16:24 |
jojomartius |
yes.. thats the theory ;) |
# |
Mar 8th 2018, 16:23 |
lorenzo |
or at least that will give you a good hint |
# |
Mar 8th 2018, 16:23 |
lorenzo |
in theory the format should be dependent on the browser’s locale |
# |
Mar 8th 2018, 16:22 |
ricksaccous |
in view always divide number by 100 |
# |
Mar 8th 2018, 16:22 |
ricksaccous |
just take out all , or . and multiply number by 100 |
# |
Mar 8th 2018, 16:22 |
ricksaccous |
store number as int and then use step=any in the textfield |
# |
Mar 8th 2018, 16:20 |
jojomartius |
but what i dont like is that i need to know how the user will enter its number... if the german user uses an english format, it returns 0 and the otherway around ;) |
# |
Mar 8th 2018, 16:14 |
jojomartius |
good idea ;)) thanks |
# |
Mar 8th 2018, 16:05 |
lorenzo |
@jojomartius my suggestion would be to either use a beforeMarshal callback or use a custom database type |
# |
Mar 8th 2018, 16:04 |
jojomartius |
;) sounds like a quite good solution ;) and if we do this in the model directly while setting the value it should happen "automatically" ;) |
# |
Mar 8th 2018, 16:03 |
lorenzo |
you can maybe read the locale from the user agent string of the user, and pre-process the inputs with that function |
# |
Mar 8th 2018, 16:03 |
lorenzo |
@jojomartius https://api.cakephp.org/3.5/class-Cake.I18n.Number.html#_parseFloat |
# |
Mar 8th 2018, 16:02 |
jojomartius |
Hey there, I'm using cake 3.x and had issues with the formhelper or lets call in number inputs. Is there an official way to correct decimal numbers (from number inputs) comming from IE with commas as decimal seperator in real floats? |
# |
Mar 8th 2018, 16:00 |
lorenzo |
find StatementDecorator in our github repo |
# |
Mar 8th 2018, 15:59 |
neon1024 |
Wow, quite a bit then! Thanks, I’ll have a read of the code an see if a more concrete implementation helps get it into my brain |
# |
Mar 8th 2018, 15:58 |
lorenzo |
formatResults is a decorator of the result set |
# |
Mar 8th 2018, 15:58 |
lorenzo |
the code that converts the rows to entities is a decorator of the statement… |
# |
Mar 8th 2018, 15:58 |
lorenzo |
the code that casts the results to the right type (int, dates…) is a decorator of the statement |
# |
Mar 8th 2018, 15:57 |
lorenzo |
the statement object is a decorator for pdo statement |
# |
Mar 8th 2018, 15:57 |
lorenzo |
I sued decorator for a bunch of stuff, but where it is more obvious is in the result set |
# |
Mar 8th 2018, 15:56 |
neon1024 |
@lorenzo The decorator in the ORM, is that for the query building, the sql, or the entities? I’m unsure |
# |
Mar 8th 2018, 15:55 |
ricksaccous |
heh |
# |
Mar 8th 2018, 15:55 |
ricksaccous |
so no issue |
# |
Mar 8th 2018, 15:55 |
ricksaccous |
i see, so the issue with the docs is actually probably a difference in version between me and repo rather than a bug |
# |
Mar 8th 2018, 15:55 |
em. |
ok, thx! |
# |
Mar 8th 2018, 15:55 |
lorenzo |
haha |
# |
Mar 8th 2018, 15:55 |
lorenzo |
@em. that is a really bad error message, it actaully should say “the table you are trying to use does not exist. please check your database or for typos” |
# |
Mar 8th 2018, 15:55 |
savant |
my favorite pattern is to write code and have @lorenzo write the tests |
# |
Mar 8th 2018, 15:54 |
lorenzo |
decorator is one of my favorite patterns :slightly_smiling_face: |
# |
Mar 8th 2018, 15:54 |
em. |
This is something new… “Cannot describe sessions. It has 0 columns.” |
# |
Mar 8th 2018, 15:54 |
neon1024 |
Or try `composer outdated` |
# |
Mar 8th 2018, 15:54 |
ricksaccous |
ok |
# |
Mar 8th 2018, 15:54 |
ricksaccous |
ahhhh |
# |
Mar 8th 2018, 15:54 |
neon1024 |
I’d have a look in your composer.lock |