CoderDojo / community-platform

Zen, the CoderDojo Community Platform!
https://zen.coderdojo.com
MIT License
121 stars 55 forks source link

Scroll to validation error on all forms #605

Closed tangentfairy-zz closed 9 years ago

tangentfairy-zz commented 9 years ago

I was creating an event and entered everything but the name, hit publish and nothing happens because I left the name field empty.

Can we have an event on the publish/save click so that if there is a validation error the user is scrolled to the first validation error on the page.

tangentfairy-zz commented 9 years ago

Technical spec We have this on the edit dojo form, so it can easily be used as an example. See here https://github.com/CoderDojo/cp-zen-platform/blob/cf2e0c2eaecd208b91fc1bba1e2871e8f155059b/web/public/js/controllers/edit-dojo-controller.js#L36 and here https://github.com/CoderDojo/cp-zen-platform/blob/4674958d8d71c899c4fb199d402b3eb367f02efc/web/public/templates/dojos/dojo-form.dust#L287 for where it is already used.

You'll need to edit here https://github.com/CoderDojo/cp-zen-platform/blob/cf2e0c2eaecd208b91fc1bba1e2871e8f155059b/web/public/templates/dojos/events/dojo-event-form.dust#L265 and add a new function to scroll to validation here https://github.com/CoderDojo/cp-zen-platform/blob/cf2e0c2eaecd208b91fc1bba1e2871e8f155059b/web/public/js/controllers/dojo-event-form-controller.js

tangentfairy-zz commented 9 years ago

This is live now, thanks to @iwtcs and congrats on your first deployed change!