Skip to main content

Documentation

In this documentation, you will find all the important information about the plugin – from installation and configuration to usage and extension.

Hooks

In this post, we’ll walk you through:


With hooks, you can react to what happens in Cevento or adjust its behaviour – without touching the plugin itself, so your changes survive every update. Put your code in a small custom plugin or in the functions.php of your (child) theme.

There are two kinds of hooks:

  • Actions (add_action) let you run your own code at a certain moment, e.g. when a booking comes in. Their return value is ignored.
  • Filters (add_filter) hand you a value to change. Always return a value of the same type – if you don’t want to change anything, simply return the first parameter as it is.

Many hooks pass the event as an array. Its structure is described under Event Data Structure. Hooks that only exist in Cevento Pro are marked with Pro.

Bookings

The booking array

The booking hooks pass the booking as an array – one row of Cevento’s bookings table:

Key Type Description
id int ID of the booking
event_id int ID of the event
status int 1 confirmed, 0 pending, -1 cancelled, -2 cancelled by the participant, -3 awaiting refund, -4 refunded; Pro: 10 waiting list, 11 waiting for payment
submission_data array The submitted form values, keyed by field key
places int Number of places the booking occupies
lang string|null Language of the booking (e.g. with WPML)
payment_status int Paid events (Pro): 0 in the cart, 1 paid, 2 awaiting payment, 3 on hold
via_admin int 1 if the booking was created in the admin area
ticket_scanned_at int|null Unix timestamp of the ticket scan (Pro)
created_at int Unix timestamp of the booking

The status hooks fire right before the new status is saved. So in cevento/booking_confirmed and cevento/booking_canceled, $booking['status'] usually still holds the previous status – handy if you want to know where a booking came from.

cevento/booking_received

Action – a new booking has been saved. (Sending the booking email again from the bookings table does not trigger this hook.)

Parameter Type Description
$event array The event
$booking array The new booking
$sendEmail bool Whether emails are sent for this booking (e.g. false for bookings created silently in the admin area)
add_action('cevento/booking_received', function ($event, $booking, $sendEmail) {
    // e.g. pass the booking on to your CRM
}, 10, 3);

cevento/booking_confirmed

Action – a booking is confirmed: by an admin, by a paid order, when a place on the waiting list is accepted, or when a cancellation is revoked.

Parameter Type Description
$event array The event
$booking array The booking
add_action('cevento/booking_confirmed', function ($event, $booking) {
    // Execute something when the booking is confirmed
}, 10, 2);

cevento/booking_paid

Action, Pro – the payment of a booking has arrived (fires once per booking, right after cevento/booking_confirmed). Same parameters as cevento/booking_confirmed.

cevento/booking_canceled

Action – a booking is cancelled, e.g. by an admin in the bookings table. (Cancellations by participants themselves use cevento/booking_user_canceled, see below.) Same parameters as cevento/booking_confirmed.

cevento/booking_user_canceled

Action – a participant cancels their booking via the cancellation link. Same parameters as cevento/booking_confirmed.

cevento/booking_places

Filter – how many places a booking occupies. Applied when a booking is saved and when it is edited in the admin area.

Parameter Type Description
$places int The places so far: 1 for a new booking, the current value when a booking is edited
$fieldBag FieldBag The submitted form, see FieldBag
$event array The event

Returns: int – the number of places (at least 1).

Do you have form fields that should occupy more than one place when selected? Then this is your filter:

add_filter('cevento/booking_places', function ($places, $fieldBag, $event) {
    $field = $fieldBag->getField('Bringing a partner');

    return $field && $field->getValue() ? 2 : $places;
}, 10, 3);

Cevento itself uses this filter to count the places of a booking with the “Participants” form field:

add_filter('cevento/booking_places', function ($places, $bag, $event) {
    $totalParticipants = $bag->getTotalParticipants();
    if (!$totalParticipants || $totalParticipants < 1) {
        return $places;
    }

    return $totalParticipants;
}, 10, 3);

cevento/booking_rate_limit

Filter – the booking limit per visitor, e.g. to allow more bookings for a certain event.

Parameter Type Description
$limits array submissions (int, bookings per time window, 0 = no limit), window (int, length of the time window in seconds), held_reservations (int, Pro: unpaid reservations per visitor at the same time)

Returns: array – the limits; keys you leave out keep their value.

cevento/booking_rate_limit_client_ip

Filter – the IP address the booking limit counts a visitor by.

Parameter Type Description
$ip string The IP address, as set under Visitor IP Address Source

Returns: string – the IP address to use.

Form Validation

Validation hooks receive the submitted form as an instance of Cevento\Packages\Formbuilder\FieldBag. With it, you can read the individual fields and their values and add your own validation errors – see FieldBag.

cevento/validate and cevento/validate/form={ID}

Action – runs after the built-in validation of every booking form, or only of the form with this ID.

Parameter Type Description
$fieldBag FieldBag The submitted form
$event array|null The event (null in the form preview)
$validationMeta array isPreview, isEdit (an admin edits a booking), isCreate (an admin creates a booking), Pro: isWaitlist – all bool
<?php

add_action('cevento/validate', function ($fieldBag, $event) {
    // Retrieve field by label or key
    $nameField = $fieldBag->getField('Name');

    // Get field value
    $nameValue = $nameField->getValue();

    // Trigger a validation error for a specific field
    if (strlen($nameValue) < 3) {
        $nameField->addError('The name must be at least 3 characters long.');
    }

    // Add a global error displayed above the form
    $fieldBag->addGlobalError('Any global error message can be displayed here.');
}, 10, 2);

add_action('cevento/validate/form=1', function ($fieldBag, $event) {
    // Specific validation rules for the form with ID 1 can be added here
}, 10, 2);

cevento/form/before_field_validation

Action – runs right before the fields are validated. A good moment to adjust the submission first: set or overwrite field values, or make fields required (or optional) depending on other answers. Same parameters as cevento/validate.

Values you set here are validated and stored just like the ones the visitor entered. You can set them on the field bag (by field key or label) or on the field itself:

add_action('cevento/form/before_field_validation', function ($fieldBag, $event) {
    // Tidy up a value before it is checked and saved
    $name = $fieldBag->getField('Name');
    $name->setValue(trim($name->getValue()));

    // Fill in a field yourself, e.g. where the booking came from
    $fieldBag->setValue('Source', 'website');

    // Several values at once (by key or label)
    $fieldBag->setValues([
        'field_80799639' => 'yes',
        'Newsletter'     => '',
    ]);
}, 10, 2);

Making a field required depending on other answers

Validation runs right after this hook, so a field you mark as required here is checked as such:

add_action('cevento/form/before_field_validation', function ($fieldBag, $event) {
    $invoice = $fieldBag->getField('I need an invoice');
    $company = $fieldBag->getField('Company');

    // "Company" is only required if an invoice was requested
    if ($invoice && $company) {
        $company->setValidationRule('required', $invoice->hasValue());
    }
}, 10, 2);

This only changes what is checked when the form is sent – the form itself doesn’t mark the field as required. If a field should always be required (and show its asterisk), use cevento/prepare_field below instead. For rules visitors should see while filling in the form, the conditional fields of the form builder (Cevento Pro) are the most convenient way.

Form Fields and Rendering

cevento/prepare_field

Filter – the configuration of a form field right before it is used, both for showing the form and for checking a submission. Lets you change labels, options, requirements or other settings dynamically – for exactly the fields you need:

Hook Applies to
cevento/prepare_field every field
cevento/prepare_field/type={type} every field of this type: text, email, number, date, select, checkbox, textblock; Pro: group, repeater_group, participants_group
cevento/prepare_field/label={label} fields with exactly this label, as entered in the form builder
cevento/prepare_field/key={field key} (or simply cevento/prepare_field/{field key}) the field with this key

If several of them apply to a field, they run in this order – from general to specific, so the most specific one has the final say.

Parameter Type Description
$fieldConfig array The field configuration as saved in the form builder (e.g. key, type, label, validation, display and the field’s other settings)

Returns: array – the field configuration.

// Every email field gets a placeholder
add_filter('cevento/prepare_field/type=email', function ($fieldConfig) {
    $fieldConfig['display']['placeholder'] = 'name@example.com';
    return $fieldConfig;
});

// The field "Company" is always required – and marked as such in the form
add_filter('cevento/prepare_field/label=Company', function ($fieldConfig) {
    $fieldConfig['validation']['required'] = true;
    return $fieldConfig;
});

// One specific field
add_filter('cevento/prepare_field/key=field_80799639', 'CallbackHandler');

Labels can be changed in the form builder at any time (and may differ between languages on a multilingual website). For code that should keep working in the long run, the field key is the safer choice.

cevento/form/hidden_fields

Filter – hidden fields of a booking form.

Parameter Type Description
$hiddenFields array Field name => value
$formId int ID of the form
$isPreview bool Whether the form is shown in the preview

Returns: array – the hidden fields.

Output around the form fields

Actions – anything these actions echo is added to the form at that spot.

Hook Parameters
cevento/form/before_fields and cevento/form/before_fields/{form ID} $formData (array, the form), $eventId (int)
cevento/form/after_fields and cevento/form/after_fields/{form ID} $formData (array), $eventId (int)
cevento/form/before_field_render $field (the field object), $formData (array)
cevento/form/after_field_render $field (the field object), $formData (array)

Just like cevento/prepare_field, the two field hooks can be aimed at the fields you need: add /type={type}, /label={label} or /key={field key} (or simply /{field key}) to the hook name – or leave it as it is for every field. Before a field, the general hooks come first; after it, the most specific ones. That way, the most specific output always sits closest to the field.

add_action('cevento/form/after_fields/1', function ($formData, $eventId) {
    echo '<p class="my-note">We will confirm your booking within 24 hours.</p>';
}, 10, 2);

// A short hint below every email field
add_action('cevento/form/after_field_render/type=email', function ($field, $formData) {
    echo '<p class="my-hint">We only use your email address for this booking.</p>';
}, 10, 2);

Emails

cevento/email/user_attachments

Filter – the attachments of an email to a participant. By default, booking emails come with the iCal file of the event.

Parameter Type Description
$attachments array File name => absolute path of the file
$type string The email: new_booking, confirm_booking, cancel_booking, user_cancel_booking, event_reminder; Pro: waitlist_booking, waitlist_confirm, waitlist_confirm_paid
$event array The event
$booking array The booking
$email string The recipient’s email address

Returns: array – the attachments.

add_filter('cevento/email/user_attachments', function ($attachments, $type, $event, $booking, $email) {
    if ($type === 'confirm_booking') {
        $attachments['directions.pdf'] = WP_CONTENT_DIR . '/uploads/directions.pdf';
    }

    return $attachments;
}, 10, 5);

Events

cevento/event/is_payable

Filter – whether an event is paid. Cevento Pro decides this via the WooCommerce integration.

Parameter Type Description
$isPayable bool false by default
$event array The event

Returns: bool.

cevento/event/price_html

Filter – the price shown for a paid event.

Parameter Type Description
$priceHtml string The price as HTML (empty by default)
$event array The event

Returns: string – HTML.

cevento/event_schema

Filter – the structured data (schema.org Event, as JSON-LD) that Cevento adds to every event page for search engines.

Parameter Type Description
$schema array The schema
$event array The event

Returns: array – the schema; an empty value removes it from the page.

cevento/schema/offer

Filter, Pro – the offers part of the schema of a paid event. Same parameters as cevento/event_schema, with $offer (array) instead of $schema.

cevento/event_to_post_terms and cevento/event_to_post_content

Filters – when an event is converted into a post, only the content and title are transferred by default. These filters let you adjust the categories and the content of the new post.

Hook Parameters Returns
cevento/event_to_post_terms $terms (array of WP_Term, the post categories with the same names as the event’s categories), $event (array) array of WP_Term
cevento/event_to_post_content $content (string, the event’s HTML description), $event (array) string – HTML
add_filter('cevento/event_to_post_terms', function ($terms, $event) {
    $terms[] = get_term_by('slug', 'archive', 'category');

    return array_filter($terms);
}, 10, 2);

add_filter('cevento/event_to_post_content', function ($content, $event) {
    return $content . '<p>This event took place on ' . esc_html($event['startsAt']->format('d.m.Y')) . '.</p>';
}, 10, 2);

Shortcodes

cevento/shortcodes

Filter – the shortcodes Cevento registers – and that the shortcode builder and the page builder elements offer.

Parameter Type Description
$shortcodes array Class names of shortcodes extending Cevento\Packages\View\Shortcodes\Shortcode

Returns: array of class names.

cevento/shortcode_present

Filter – Cevento only loads the scripts and styles of a shortcode on pages that use it. If your page builder stores its content somewhere Cevento doesn’t look (not in the post content or as a block), tell Cevento here.

Parameter Type Description
$isPresent bool false by default
$shortcode Shortcode The shortcode
$post WP_Post The current post

Returns: bool – true if the shortcode is used on this page.

cevento/meta_shortcode/output

Filter – the output of the [cevento_meta] shortcode, e.g. to format a field of your own differently, or to add a label.

Parameter Type Description
$output string The formatted value (escaped HTML), '' if the event has no value for the field
$key string The requested field key, e.g. datetime or my_dresscode
$evt array The event (see Event::get())

Returns: string – HTML. Escape any values you add yourself.

add_filter('cevento/meta_shortcode/output', function ($output, $key, $evt) {
    if ($key === 'my_dresscode' && $output !== '') {
        return '<strong>' . esc_html__('Dress code:', 'my-theme') . '</strong> ' . $output;
    }
    return $output;
}, 10, 3);

Adding Your Own Fields

Need a setting of your own, an extra piece of information per event, or a special kind of form field? These three filters let you add them – they then look and work just like Cevento’s own.

cevento/global_settings

Filter – the tabs and fields of the settings page (Cevento → Settings). Add a field to an existing tab or a tab of its own; Cevento saves the values for you.

Parameter Type Description
$settings array Tab key => tab: label (name of the tab), title (heading), fields (field key => field), and optionally tabs (sub-tabs, each with a label and the list of its field keys)

Returns: array – the tabs.

add_filter('cevento/global_settings', function (array $settings) {
    // A new field in the tab "General"
    $settings['general']['fields']['cevento_my_contact_phone'] = [
        'label'             => 'Contact phone',
        'instructions'      => 'Shown below every booking form',
        'type'              => 'text',
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ];

    // A tab of its own
    $settings['my_plugin'] = [
        'label'  => 'My Plugin',
        'title'  => 'My Plugin Settings',
        'fields' => [
            'cevento_my_show_badge' => [
                'label'        => 'Badge',
                'instructions' => 'Show a badge on featured events',
                'type'         => 'bool',
                'default'      => 0,
            ],
            'cevento_my_badge_style' => [
                'label'   => 'Badge style',
                'type'    => 'select',
                'options' => ['new' => 'New', 'popular' => 'Popular'],
                'default' => 'new',
            ],
        ],
    ];

    return $settings;
});

// Reading a value (returns the default as long as nothing was saved)
$phone = \Cevento\Packages\Settings\Settings::get('cevento_my_contact_phone');

A field can have these keys:

Key Description
type text, number, bool (switch), select, color, media, wysiwyg, emails (list of email addresses), html (only shows the HTML given in html)
label The name of the field
instructions, description, information Help texts for the field (all optional)
default The value as long as nothing was saved
options For select: value => label, or a function returning them
sanitize_callback Optional: a function that cleans the value before it is saved, e.g. sanitize_text_field or absint

Start your field keys with cevento_ and a prefix of your own (e.g. cevento_my_…): they are stored as WordPress options under exactly that name, and Cevento then notices right away when they change. Tabs with sub-tabs (e.g. “Display”) also list their fields per sub-tab: to add a field there, add its key to $settings['display']['tabs']['general']['fields'] as well.

cevento/event_metadata

Filter – the tabs and fields of the event editor. Add a field to an existing tab or a tab of its own; the values are saved with the event.

Parameter Type Description
$settings array Group key => group, shown as tabs in the event editor: general (Event Settings, with the sub-tabs content, datetime, address, ical), bookings, email. Each group has a label, fields (field key => field) and optionally tabs (sub-tabs, each with a label and the list of its field keys)

Returns: array – the groups.

add_filter('cevento/event_metadata', function (array $settings) {
    // A new field in "Event Settings" → "Content"
    $settings['general']['fields']['my_dresscode'] = [
        'label'       => 'Dress code',
        'description' => 'Shown on the event page',
        'type'        => 'select',
        'options'     => ['' => 'None', 'casual' => 'Casual', 'formal' => 'Formal'],
    ];
    $settings['general']['tabs']['content']['fields'][] = 'my_dresscode';

    // A tab of its own
    $settings['my_sponsoring'] = [
        'label'  => 'Sponsoring',
        'fields' => [
            'my_sponsor_show' => [
                'label' => 'Show sponsor',
                'type'  => 'bool',
            ],
            'my_sponsor_name' => [
                'label'      => 'Sponsor',
                'type'       => 'text',
                'conditions' => ['my_sponsor_show' => true], // only shown while the switch is on
            ],
            'my_sponsor_contact' => [
                'label'    => 'Contact person',
                'type'     => 'text',
                'required' => true,
            ],
        ],
    ];

    return $settings;
});

// Reading a value (by event ID or event array; without a saved value,
// the field's "default" – or the default you pass as third parameter)
$dresscode = Event::getMeta($eventId, 'my_dresscode');

A field can have these keys:

Key Description
type text, textarea, number, bool (switch, saved as 1 / 0), select, radio, date, time, datetime, color, media, wysiwyg, weekdays, html, repeater
label The name of the field
instructions, description Help texts (optional)
default The value as long as nothing was saved
options For select and radio: value => label, or a function returning them
placeholder For text fields
required true: the event can only be published once the field is filled in (otherwise it is saved as a draft and the field is pointed out)
conditions Field key => value: the field is only shown while the other field has this value

The field key is the name of the custom field the value is stored in. Give your keys a prefix of your own (e.g. my_…), so they never get in the way of Cevento’s own fields.

Showing your fields on the website

You don’t need any code to show your own event fields: the [cevento_meta] shortcode outputs any field of the event editor – Cevento’s own and the ones you add with cevento/event_metadata. Use the field key as key:

[cevento_meta key="my_dresscode"]
[cevento_meta key="my_sponsor_name" id="123"]

Without id, the shortcode shows the field of the event of the current page – ideal for a page builder or theme template for single events. In the Shortcode Builder and the page builder elements (Elementor, YOOtheme, Gutenberg, …), your fields appear in the Field dropdown automatically, shown as “Label (key)”.

These keys are available for every event:

Key Tab in the event editor Shows
datetime – (formatted) Date and time like on the event page, including the end, if there is one
address – (formatted) The location in one line: venue name, street, ZIP code and city, country
places – (formatted) The available spots, e.g. “12 spots available” – empty for events with an external booking link
price – (formatted) The price of a paid event (Cevento Pro with WooCommerce) – empty for free events
infos_featured Event Settings → Content Featured event (Yes/No)
infos_hidden Event Settings → Content Event hidden (Yes/No)
infos_html_description Event Settings → Content The description of the event page, with its formatting
datetime_all_day Event Settings → Date & Time All-day event (Yes/No)
datetime_from Event Settings → Date & Time Start date and time (without the time for all-day events)
datetime_until Event Settings → Date & Time End date and time – empty for events without an end
infos_address_name Event Settings → Address Venue name
infos_address Event Settings → Address Street and house number
infos_address_zip Event Settings → Address ZIP code
infos_address_city Event Settings → Address City
infos_address_country Event Settings → Address Country
infos_address_coords Event Settings → Address Coordinates of the location
infos_description Event Settings → iCal The plain-text description of the iCal file
booking_active Bookings Bookings enabled (Yes/No)
booking_external Bookings The external booking link
booking_form Bookings The name of the booking form
booking_confirm_bookings Bookings Bookings must be confirmed (the chosen option)
booking_cancellation Bookings Self-service cancellation (the chosen option)
booking_cancellation_deadline Bookings Cancellation deadline in days – empty if the global setting is used
booking_waitlist Bookings Pro – Waitlist (the chosen option)
booking_ticket_enabled Bookings Pro – Tickets (the chosen option)
booking_max_places Bookings Maximum number of spots – empty if there’s no limit
booking_available_from Bookings Start of the booking period – the default period, if none is set
booking_available_until Bookings End of the booking period – the default period, if none is set
ticket_logo Tickets Pro – The ID of the event’s ticket logo (only with tickets enabled)
ticket_custom_text Tickets Pro – The event’s ticket text (only with tickets enabled)
ticket_footer_text Tickets Pro – The event’s ticket footer (only with tickets enabled)

Plus every key you add with cevento/event_metadata. The e-mail templates of an event (email_…) are not available.

The value of your own fields is formatted according to the field’s type:

Type Output
bool “Yes” or “No”
select The label of the chosen option
datetime The date in the date format of the display settings
wysiwyg The HTML, with its formatting (filtered by wp_kses_post)
textarea The text, with line breaks kept
any other The value as escaped text – lists of values separated by commas

If the event has no value for the field, the shortcode outputs nothing.

Not every field is offered: fields of the email group, fields whose key starts with email_ and fields with 'show_in_rest' => false are left out. Use 'show_in_rest' => false for internal fields that should never show up on the website.

To change the output – e.g. to add a label or format a field differently – use the filter cevento/meta_shortcode/output (see Shortcodes). In PHP, e.g. in a theme template, you can output a field with echo do_shortcode('[cevento_meta key="my_dresscode"]');.

cevento/fieldtypes

Filter – the field types of the form builder. With a class of your own, you can add a completely new kind of form field: it then appears in the form builder like any other field, with its settings, its validation and its own look in the booking form.

Parameter Type Description
$fieldTypes array Class names of the field types, each extending Cevento\Packages\Formbuilder\Fields\Field

Returns: array of class names.

Here’s an example: a phone number field that shows the phone keyboard on mobile devices, only lets visitors type characters a phone number can contain, and checks the number when the form is sent. Since it builds on the text field, it also inherits its settings (default value, placeholder, instructions, minimum and maximum length). The plugin consists of four files:

my-plugin/
├── my-plugin.php
├── PhoneField.php
└── assets/
    ├── phone-field.css
    └── phone-field.js
<?php
// my-plugin/PhoneField.php

use Cevento\Packages\Formbuilder\Fields\Text;

class PhoneField extends Text
{
    // Unique ID of the field type – with a prefix of your own
    public static string $id = 'my_phone';

    // Name of the field type in the form builder
    public static string $name = 'Phone';

    // Icon in the form builder (SVG)
    public static function icon(): string
    {
        return '<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1 1 .4 1.9.7 2.8a2 2 0 0 1-.5 2.1L8 9.9a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.8.7a2 2 0 0 1 1.7 2z"/></svg>';
    }

    // CSS and JavaScript of the field: Cevento adds them to the <head> of the
    // booking form – once per form, and only to forms that contain this field
    public static function assets(): string
    {
        $url = plugin_dir_url(__FILE__) . 'assets/';
        $version = '1.0.0'; // change it with every update of the files, so browsers load the new ones

        return sprintf('<link rel="stylesheet" href="/%25s">', esc_url($url . 'phone-field.css?ver=' . $version))
            . sprintf('<script src="/%25s" defer></script>', esc_url($url . 'phone-field.js?ver=' . $version));
    }

    // The field in the booking form: label and input, without a wrapper
    public function render(): string
    {
        return $this->getLabelMarkup() . sprintf(
            '<input type="tel" class="my-phone-input" name="%s" id="%s" placeholder="%s" value="%s" autocomplete="tel" />',
            esc_attr($this->getName()),
            esc_attr($this->getId()),
            esc_attr($this->getPlaceholder()),
            esc_attr((string) $this->getValue())
        );
    }

    // Checks the value when the form is sent
    public function validate(?array $evt = null)
    {
        parent::validate($evt); // required, minimum and maximum length

        $value = trim((string) $this->getValue());
        if ($value !== '' && !preg_match('/^\+?[0-9 ()\/-]{6,20}$/', $value)) {
            $this->addError(__('Please enter a valid phone number.', 'my-plugin'));
        }
    }
}
/* my-plugin/assets/phone-field.css */

.my-phone-input {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* Set by phone-field.js when the number doesn't look right */
.my-phone-input.is-invalid {
    border-color: #c0392b;
    box-shadow: 0 0 0 1px #c0392b;
}
// my-plugin/assets/phone-field.js

// Listening on the document instead of the input itself: this works for
// every phone field of the form, whenever it appears on the page.

// While typing: only keep characters a phone number can contain
document.addEventListener('input', (event) => {
    const input = event.target;
    if (!input.matches('.my-phone-input')) {
        return;
    }

    input.value = input.value.replace(/[^0-9+ ()\/-]/g, '');
    input.classList.remove('is-invalid');
});

// When leaving the field: a quick hint if the number doesn't look right
// (the actual check is validate() on the server, when the form is sent)
document.addEventListener('focusout', (event) => {
    const input = event.target;
    if (!input.matches('.my-phone-input') || input.value === '') {
        return;
    }

    const isValid = /^\+?[0-9 ()\/-]{6,20}$/.test(input.value.trim());
    input.classList.toggle('is-invalid', !isValid);
});
<?php
// my-plugin/my-plugin.php – register the field type once Cevento is loaded

add_action('plugins_loaded', function () {
    if (!class_exists(\Cevento\Packages\Formbuilder\Fields\Text::class)) {
        return; // Cevento is not active
    }

    require_once __DIR__ . '/PhoneField.php';

    add_filter('cevento/fieldtypes', function (array $fieldTypes) {
        $fieldTypes[] = PhoneField::class;
        return $fieldTypes;
    });
});

These are the building blocks of a field type – only $id, $name and icon() are required, everything else has a sensible default:

Building block What it does
$id, $name Unique ID (stored with the form) and the name shown in the form builder
icon() The icon in the form builder, as SVG markup
render() The HTML of the field in the booking form – use getLabelMarkup(), getName(), getId(), getValue() and getPlaceholder()
validate() Checks the value; report problems with $this->addError()
getGeneralSettings(), getDisplaySettings(), getValidationSettings() The settings of the field in the form builder (setting key => label, type, instructions, default); read them with getState('general.…') or getValidationRule('…')
getFormattedValue(string $context) How the value is shown in emails, the bookings table and the CSV export ($context: browser, email or csv)
assets() <script> and <link> tags for the CSS and JavaScript of the field – added to the <head> of the booking form once per form, and only if the form contains the field. As the tags are in the <head>, load scripts with defer

The settings page and the event editor work with the fixed field types listed above; new field types can be added to the form builder.