Using Price Set Fields in Drupal with CiviCRM Entity

2017-05-02 07:15
Written by

As of CiviCRM Entity 2.0-beta4 the sub module called CiviCRM Entity Price Set Field provides a Drupal field type for the Event entity type.  In this article we’ll review the features of this submodule and discuss how to configure and customize it to fit your needs.


Event Registration on the Event view page

When configured to display on the Event view pages, this field generates a registration form that supports:

  • Registering multiple Participants
  • Uses the event’s price set and all price fields of any type
  • Pay later or credit card transactions utilizing CiviCRM’s payment processing
  • Profiles
  • Default values for the profile fields corresponding to the logged in user’s contact information
  • Customizable Ajax-fied confirmation and thank you panes
  • Utilizes the event’s settings such as “Is paid event?” etc..
  • Test or Live transactions

Field widget for the Event Edit Form

A “simple” field widget is provided by default for this module.  At the time of this writing, only the first price field can be edited via this widget.  


Getting Started

CiviCRM Entity and CiviCRM Entity Profile are dependencies for CiviCRM Entity Price Set Field. Go to the Drupal module page and enable all three modules and enable CiviCRM Entity Price Set Field, CiviCRM Entity, and CiviCRM Entity Profile.

Once enabled, you can add the Price Set Field to the Event Entity Type.

  • Go to the Event Manage Fields form at “/admin/structure/civicrm-entity/civicrm_event”
  • Scroll to the “Add New Field” section, enter a Label, and select the ‘CiviCRM Entity Price Set’ field type, for this example select the “Simple -- one price field” widget
  • There’s no special field or field instance settings, so just click save until you’re back to the Manage Fields page
  • Now go to the Manage Display Full Content form at “/admin/structure/civicrm-entity/civicrm_event/display/full
  • Set the new field to display
  • There is a field formatter setting to optionally submit test transactions
  • Pat yourself on the back, you’re setup to take registrations from the Drupal based Event view pages at /civicrm-event/[id]

Please note that the registration form takes into account the different settings on the CiviCRM Event.  For instance it will only enable CC transactions and render a billing block if the “Paid Event?” checkbox is checked. The form conforms to registration start and end dates, only renders if Online Registration is enabled.  The form checks to see if Max Participants has been reached, even when adding additional participants. Additional participants can only be added if “Allow Multiple Registrations” is enabled.

To learn more about registration form, how transactions work with the Contribution API, and how it can be customized, please continue reading on


Great Work - thank you! 

Is there any chance this would work in combination with the CiviCRM<->Drupal Webform Integration? I mean to set up a Webform integrated with CiviCRM and pull the price options via your module?

That would be amazing as one of the shortcomings there is that the Webform Integration cannnot pull price sets from CiviCRM  (afaik).


Well there's nothing in there that will integrate directly with the Webform CiviCRM project.

There are some helper functions that get the price set for an event, and load the price set, and price set fields for the set, as their Drupal entity equivalents, organized in an indexed array. That may be useful, but it won't generate the Webform components.

Not using Webform CiviCRM was design choice.  We wanted to mimic what CiviCRM would output on its native registration page, with the same business rules, but done completely in Drupal API and FAPI, processing done by the CiviCRM API.  If you want different fields or to change the order of them for the profile, then just edit the CiviCRM profile(s) in the normal fashion. Same for price sets/ price fields.

A Rule event does get triggered after a successful registration, and you can add Rules actions to do some post processing. The rule has the participant and contact entities available.

There is also a rule event that triggers for a successful CC transaction, that has the Contribution entity available to it...


Can I set up a reaction rule based on a civi entity price set choice? 

i.e. if someone buys t-shirt price set item, add to X group?