Sneak Peek at 4.5 for Developers

2014-03-10 17:57
Written by

The CiviCRM community is hard at work on version 4.5 and even in its pre-alpha state I have to say it is looking really good! I'll do another blog in a few weeks about all the features and improvements users have to look forward to. But developers, this one is for you. Whether you maintain a CiviCRM extension, submit pull-requests, or develop customizations for your sites, you definitely want to read on...

FIrst, the bad news:

Yes there are a few breaking changes in 4.5 so let's get those out of the way first. As always, we try to keep the API as stable as possible, so don't worry no breakage there. But if your code relies on Civi's internal functions or packages, check this out:

  • Upgraded jQuery and jQuery UI. We always try to keep up with the latest version of javascript libraries, but this one is a particuarly big bump. Read about all the breaking changes in the latest jQuery here.
  • Autocomplete plugin removed. We had an old jQuery autocomplete plugin that predates the one in jQuery UI. If your custom form includes an autocomplete, you'll need to at minimum change a few params to match what's expected by the new jQuery UI autocomplete. Or better yet, check out the new EntityRef widget.
  • Tab Interface Upgrades. Prompted by some breaking changes to the UI.tabs widget our standard tab-form interface has gotten some improvements. Implementation now requires a great deal less boilerplate code and it supports advanced features like ajax submission of forms and popup links and buttons.

Lots of good news:

Here are some great new features you can start taking advantage of:

  • New EntityRef Field: A slick widget for autocomplete/select of contacts, events, tags, option values, really anything with an api.
  • Unobtrusive Notifications: A new alternative to CRM.alert - tell the user things are going fine without having to pop-up a big bubble (let's save those for only when we really need their attention).
  • New Select2 widget: CiviCRM forms have gotten a real facelift thanks to jQuery.select2, and we've built several other new features on top of it, including the addSelect form helper.
  • In-place edit of option lists: the new CRM_Core_Form method addSelect gives some nice benefits including automatic fetching of options from the api. Showing an edit button for quick-edit of option lists is especially convenient.
  • Lo-dash in core: Lo-dash (an updated fork of underscore) is a great utility and is now available to all civi scripts. Go forth and write better javascript!

Even better: New AJAX framework!

There are so many new ajax tools in 4.5 I think it merits being called a framework.

  • New api wrapper: The new CRM.api3() function supports multiple bundled api requests and returns a jQuery deferred object.
  • Widgetize dynamic content with $().crmSnippet
  • Load content in a popup or inline with CRM.loadPage
  • AJAX forms made easy with CRM.loadForm
  • AJAX search results: no more waiting for page loads when paging, sorting, or displaying more results
  • Respond to changes on the page by listening to triggered events

Eye Candy

Add an event registration without leaving the contact summary page.

The event selector uses the new entityRef widget to give an infinite-scrolling, searchable list of events. No more need for "show past events" and "past 3 months" buttons.

Create a relationship right from the search form.

This screenshot also shows off the new entityRef widget for contacts - type of contact you can select/create changes dynamically based on the selected relationship type.

Change any option list on-the-fly.

Now you don't have to go searching through the admin menus for your option list. Even works for custom fields.

Let's Have Fun with It

Come learn more about all this cool stuff at my CiviCON SF presentation: CiviCRM 4.5 for Developers.

Filed under