SugarCRM custom form validation with UnderscoreJS

bsoremsugar —  August 19, 2013 — 3 Comments

UnderscoreJS is a javascript utility library that builds upon jQuery and BackboneJS for building modern web applications. It enables you to write javascript code in a more functional programming style, without having to extend the base Javascript objects.

Cédric Mourizard, the lead developer at SugarCRM partner Synolia, came across this library and found an easy way to use it for adding custom form validation to Sugar forms. You can do it yourself by following these easy steps..

  • Step 1: Include underscoreJS and custom validation in your metadata so that it’s loaded in the page load.

  • Step 2: Use _.wrap function to add your custom validation before the Sugar original check_form function which validates the form with Sugar rules

  • Step 3: Do a Quick Repair & Rebuild to apply the changes

Thanks Cedric for this tip!

3 responses to SugarCRM custom form validation with UnderscoreJS

  1. 

    How do you apply the same concepts in Sugar 7?

    • 

      Asked someone internally, and here’s what he said…

      “Sugar 7 uses Underscore.js already so you don’t need to include it in order to use _.wrap(). In Sugar 7, validation works a bit different though. He’d want to create a custom Record controller (a new record.js) for the module he wants to change. In the custom Record controller he should be able to _.wrap(this.model.validate) with his own function to do the same thing.”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s