Looking at backbone form validation in 2019.2. I c...
# suitecommerce
k
Looking at backbone form validation in 2019.2. I can see there are form validation occurring on the login register page prior to form submit. I have a custom form and custom model where I have form controls added in the template, bindings assigned in the view and the validation object in my model. Outside of setting up a form submit, I cannot get validation to occur prior to submitting the form. Any thoughts?
s
Well a simple answer is to use the beforeLogin and beforeRegister events on the LoginRegisterPage component to prevent submission if validation fails. As for the validation itself, I'm a bit confused about what's going on exactly. Are you saying you have an entirely separate form with its own model and service that you want to submit at the exact same time using the same submit button?
If you're operating an entirely separate form then I would make sure you're using a form view class, for example, because they are have inner works to tie form submit to validation
I don't know what your customisation is, but if it's a custom entity field (or it could be a custom entity field) then I would recommend just working that into the existing form, rather than creating a separate one
k
Hey @Steve Goldberg, thanks for the input! We’ve extended the addToCart functionality and are collecting custom data regarding the item being added. We’ve got a form rendering as a modal to capture the input. Turns out the customization is referencing the product model as opposed to the custom model. I was able to get validation messages populating prior to the form being submit.