Thanks Jose, I never thought of that.  I was trying to go straight
javascript not remembering that I have the opportunity to do more in the
controller when errors are returned.

I'll try it out tomorrow and report back.

-Jim


On Wed, Jul 8, 2020 at 5:41 PM Jose C <houdinihoun...@gmail.com> wrote:

> Hi Jim,
>
> Just got a minute... I use something like this to scroll to and highlight
> the first field in a long form (but not within a Collapse structure).   Off
> the top of my head, you're submitting to web2py, so in the controller:
>
> if form.process().accepted:
>     <all good>
> elif form.errors:
>     focus_field = next(iter(form.errors.keys()))
>
> return dict(........., focus_field=focus_field)
>
>
> then, in the view:
>
>     {{ if focus_field: }}
>         <script>
>             $(function() {
>                $("[name='{{=focus_field}}']").focus();
>             });
>         </script>
>     {{pass}}
>
> Could something like that work in your case? On field focus, does the
> collapse open automatically?
>
> HTH,
>
> Jose
>
>
>
>
>
> How about in your controller,
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/Gs5tr2lNIgQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/d189309d-a7e4-4fac-a007-02412532c1cco%40googlegroups.com
> <https://groups.google.com/d/msgid/web2py/d189309d-a7e4-4fac-a007-02412532c1cco%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAERBpoDwf1hKxrSLqypzjch1-CMNTCvWQNmS4Q%3Du3qHuVcbrPA%40mail.gmail.com.

Reply via email to