atk4 / ui

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

Activate Accordion or Tab on validation error #1728

Open mkrecek234 opened 2 years ago

mkrecek234 commented 2 years ago

I am using heavily Acccordion sections to structure forms (e.g. Customer, Address, Payment, Shipping, Tax) - the way I do this is to make one form, and inside the form we have the Accordions.

However if a Validation for a field inside a closed Accordion fails, it seems to the user nothing happens on Submit. Can we automatically open the Accordion(s) where fields with failed Validation messages are present?

mvorisek commented 2 years ago

Is there any current demo on which this issue can be reproduced or can you post a minimalistic code to reproduce?

mkrecek234 commented 1 year ago

@mvorisek No, there is not yet an example but it is very simple: If you have a form with an Accordion layout inside, and one field does not validate, the form is reloaded on save, the error message is attached to the failing field, but the user can't see it if the field is in one of the (closed) Accordions. Very confusing for the user. This also would apply to tabs I assume.

Improved behaviour: If validation fails, for the first invalid field that is inside an Accordion, that Accordion is activated automatically.

@ibelar something for you eventually?

mvorisek commented 1 year ago

Accordion Section activate on error is/was supported and was fixed by https://github.com/atk4/ui/pull/1863.

This issue is about general support. A test for Accordion and Tab should be added. And both must be activated even if insined nested structure, like Accordion->Tab->Tab->Accordion->section with an error.

mvorisek commented 1 year ago

https://app.codecov.io/gh/atk4/ui/pull/2032/blob/src/Form/Layout/Section/Accordion.php - needs to be covered by a Behat test