-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate form on blur option #510
Comments
We would fetch the entire page from the server, and then try to replace the fields without loosing what the user has already entered? If the page contains other things besides the form, they would be loaded but ignored? Or would we do a full page reload, but in JavaScript ? If so, why not do a normal form validation and let the browser reload the page? |
Yes, what it did is just replace the form innerhtml with the parsed form from the server.
If we replace only the form inner html, the rest of the page will remain untouched.
Triggering form validation with blur events leads to many reloads so if we do a full page reload it's visible and not super nice. Swapping the inner html of the form leads to a better experience I think. I'm not sure that what I did was the best way to achieve what I wanted : make dependent fields visible without user click and without full page reload. Do you see other ways to achieve that ? What I did was to add an event listener on blur events and submit events, on blur events, dispatch the submit event and on submit event send form data via ajax, get an html response back from the server, parse it and swap the inner form with the new one if the html is different. |
But with the page reload, the browser gives feedback to the user that the page is loading. Without it, we just load it in the background, and replace a form that the user has potentially already interacted with, losing their changes. I think this is a worse annoyance than a page reload. |
What do you mean the page jitters ? Modern browsers should all be able to handle page refresh without jitter. This is what the official multistep form demo looks like for me: The browser lets you know that it is loading when it is, but the page never loses its responsiveness, and elements don't jump around.
It is generally a good UX practice to split up long forms in multiple steps anyways; in this case I think it would be even faster for the user if they started on a page with four buttons "Article", "Traduction", "Issu d'un colloque" and "dépôt de données", and then landed on the form. |
You are right about the problem with the icons and the list selection flashing during page load. This is a bad experience for everyone, not only in multistep form, and I'd like to work on that.
I generally just use hidden form fields to keep the form state between pages. This way the browser's back button just works natively to navigate back to the previous form step.
Be careful if you continue this way, to properly initialize sqlpage components that require it. For instance, selects with dropdowns use a javascript library, and won't work if they are not initialized. You can run |
What are you building with SQLPage ?
An admin panel with a long form.
What is your problem ? A description of the problem, not the solution you are proposing.
I have some dependent fields in my form that I would like to show only when a given condition in a previous field is met. To do so it's needed to add a
WHERE
clause on the dependent field and click thevalidate
button. I believe clicking on the button is not very user-friendly since we are used to more reactive forms.What are you currently doing ? Since your solution is not implemented in SQLPage currently, what are you doing instead ?
I wrote a piece of javascript to validate the form on blur and swap the new form html with the previous (so it doesn't trigger a full page reload) when the form data changes.
A clear and concise description of what you want to happen.
It would be nice to have an option in the form component like
TRUE as 'validateOnBlur
.A clear and concise description of any alternative solutions or features you've considered.
I considered adding
htmx
to the project and create a new template based on the current form.Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: