Select existing Team Name and assign Team Number

  • Cory S
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 months 1 week ago - 4 days 22 hours ago #175902 by Cory S
This plugin, TeamNumberAssignment, and new field type allows event registrants to either join an existing team or create a new team, and auto-assign a team #. Team members who register with the same team name are automatically assigned the same team number. This is event-specific. It should work for fields on both Billing and Registration Group records.

It's comprised of a plugin that you install normally, which takes care of the Team# assignment. It also adds a new SQLCustom field type, which uses SQL to lookup existing values in the database for Team Name. This field is an improvement over the existing SQL custom field because it allows you to add a new value, instead of only selecting from existing values.

Normal disclaimer, use at your own risk, not responsible for any damage caused by using this plugin.

=================
OverviewThis plugin and new field type allows event registrants to either join an existing team or create a new team, and auto-assign a team #. Team members who register with the same team name are automatically assigned the same team number. This is event-specific.

Tested Against: Events Booking 5.3.1, Joomla 5.4.0

 Components
Custom Field Type: SQLCustomFile: sqlcustom.php
Location: /administrator/components/com_eventsbooking/libraries/rad/form/field/sqlcustom.php
Type: Events Booking field type extension (NOT a plugin)
Purpose: Provides a dual-input sql-lookup field that:
  • Shows a dropdown of existing values for a field (e.g. Team Names) from the SQL query so registrants can choose an existing value
  • Provides a text input for entering a new value
  • Automatically hides the text input when an existing value is selectedFeatures
  • Executes SQL queries to populate dropdown options
  • Supports placeholders like [EVENT_ID] in SQL queries
  • Syncs dropdown and text input with JavaScript
  • Inherits validation and styling from parent RADFormFieldSQL class
Plugin: Team Number Assignment
Plugin Name: Events Booking - Team Number Assignment
Folder: teamnumberassignment
Location: /plugins/eventbooking/teamnumberassignment/
Type: Joomla Plugin (eventbooking group)
Purpose: Automatically assigns team numbers to registrants based on their team name:
- Same team name → Same team number
- New team name → Next available team number (no upper limit)
- Works for both individual and group registrations
- Configurable field IDs for flexibility 

How It Works
  1. Hooks into onAfterStoreRegistrant event
  2. Checks that field IDs are configured (shows error if not)
  3. Retrieves the Team Name from the configured Team Name field
  4. Checks if team name already exists for this event
  5. If exists: Assigns the same team number
  6. If new: Finds the highest existing team number and assigns next number (max + 1)
  7. Saves team number to the configured Team Number field
  8. For group registrations: Processes each group member individually
    • Assigns team numbers based on each member's team name
    • Handles cases where group members have different team names
    • Also processes billing record if it has a team name
This plugin is SAFE during Joomla updates - It will NOT be deleted or overwritten. Events Booking updates also will not affect this plugin.
After Events Booking Updates: Simply reinstall or update this plugin to restore the SQLCustom field type.

Detailed instructions for installing included in the package.
Last edit: 4 days 22 hours ago by Cory S. Reason: cleaned up code format, which is really horrible.

Please Log in or Create an account to join the conversation.

More
2 months 1 week ago #175903 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Select existing Team Name and assign Team Number
Thanks Cory for sharing your work back to community

Regards,

Tuan

Please Log in or Create an account to join the conversation.