atk4 / ui

Robust and easy to use PHP Framework for Web Apps
https://atk4-ui.readthedocs.io
MIT License
445 stars 106 forks source link

Multiline must use regular UI/PHP controls #810

Open PhilippGrashoff opened 5 years ago

PhilippGrashoff commented 5 years ago

Hi, I am using multiline with containsMany, and thats just a great combination! Using a money field, I noticed two things in this combination:

1) In normal Form Fields, Money fields do get rendered with number_format, always displaying 2 digits after the dot (e.g. 25.90). This currently does not happen in multiline. It seems that Persistence\UI in not involved for rendering field values. 2) When saving the data, the typecasting/normalization that takes place in normal form fields does not seem to happen. When I save a normal money field with an input like 25,90 (notice the comma as separator), this is saved as 259 in persistence. With Multiline and containsMany, the original value 25,90 is saved in the json encoded data.

I think its important to have Multiline form fields to behave as much as possible like normal form fields (which won't always be 100% possible as a different JS library is used for multiline fields). But these cases are Server Side only and shouldn't be too hard to implement. Making sure that data "flow" is the same for each form field (whether its a normal form field or a multiline field) will prevent some bad surprises :)

And: Many thanks for all the work you put in there Alain!

acicovic commented 5 years ago

These suggestions seem pretty logical and I agree.

DarkSide666 commented 5 years ago

As I mentioned to @ibelar and @romaninsh quite some time ago in Slack about Multiline - it should use same FormField decorators as a Form class uses. Only that way we can show any type of form field inside Multiline component without even worrying how it will look and act in there. Like DropDown, Lookup, Checkbox, DateTime and so on.

acicovic commented 4 years ago

@DarkSide666 I completely agree. Implementation-wise I don't know how easy this would be. Someone who has more experience with that aspect could perhaps give their opinion.

mvorisek commented 2 years ago

Currently multiline lookup is buggy, like in demo demos/form-control/multiline.php:

image

it opens with options defined in the items data instead of the source data, something must be written to fetch the data from API first