Does anyone know which model would need to be exte...
# suitecommerce
l
Does anyone know which model would need to be extended in order to add custom validation (like required) to the PO Number field, and if anything would need to be done in order_wizard_paymentmethod_purchasenumber_module.tpl? Wasn't able to figure it out after about 2 hours of looking for it in the native code so just wrote a small, quick workaround class in an hour. https://developers.suitecommerce.com/develop-your-first-extension.html#add-validation-rules-to-the-frontend-model
s
Good question. I don't think we really have a good way of hooking into existing fields and changing their validation.
I think you would need to add a checkout module and then access the model. You could probably then modify the model's validation rules via
this.model.validation
(or perhaps
this.model.prototype.validation
)
If you extend that and add a custom validation object for your field, I would imagine it would work
My only other thought is binding an event to the model and listening for a field change; but I don't think that would be a blocking / 'cancellable' event like validation is
l
It might be
OrderWizardModulePaymentMethodPurchaseNumber.prototype.wizard.model
, since
this.wizard.model.set('purchasenumber', purchase_order_number);
happens in "OrderWizard.Module.PaymentMethod.PurchaseNumber" on submit.
"OrderWizard.Module.PaymentMethod.PurchaseNumber" extends "Wizard.Module", which does
this.model = options.wizard.model;
in "initialize", so maybe I can wrap the child class initialize function and there set the validation.