Callbacks

Callbacks are entry-points for custom code in the DCA. Using callbacks you can modify static Data Container Array during runtime.

Callback functions are based on the event dispatcher pattern. You can register one or more callbacks for a certain event and when the event is triggered, the callback functions are being executed.

Callbacks are very similar to Hooks, but always bound to a specific DCA table.

Note

Since Contao 3.2.0, you can also use anonymous functions for DCA callbacks.

Global callbacks

Callback Description
onload_callback Is executed when the DataContainer object is initialized. Allows you to e.g. check permissions or to modify the Data Container Array dynamically at runtime.
oncreate_callback Is executed when a new record is created.
onsubmit_callback Is executed when a back end form is submitted. Allows you to e.g. modify the form data before it is written to the database (used to calculate intervals in the calendar extension).
ondelete_callback Is executed before a record is removed from the database.
oncut_callback Is executed after a record has been moved to a new position.
oncopy_callback Is executed after a record has been duplicated.
oncreate_version_callback Is executed after the old version of the record has been added to tl_version.
onversion_callback As oncreate_version_callback but deprecated and with different signature.
onrestore_version_callback Is executed after a record has been restored from an old version.
onrestore_callback As onrestore_version_callback but deprecated and with different signature.

Listing callbacks

Callback Description
paste_button_callback Allows for individual paste buttons and is e.g. used in the site structure to disable buttons depending on the user's permissions (requires an additional command check via load_callback).
child_record_callback Defines how child elements are rendered in "parent view".
group_callback Allows for individual group headers in the listing.
label_callback Allows for individual labels in the listing and is e.g. used in the user module to add status icons.
header_callback Allows for individual labels in header of "parent view".

Operations callbacks

Callback Description
button_callback Allows for individual navigation icons and is e.g. used in the site structure to disable buttons depending on the user's permissions (requires an additional command check via load_callback).

Field callbacks

Callback Description
options_callback Allows you to define an individual function to load data into a drop-down menu or checkbox list. Useful e.g. for conditional foreinKey-relations.
input_field_callback Allows for the creation of individual form fields and is e.g. used in the back end module "personal data" to generate the "purge data" widget. Attention: the field is not saved automatically!
load_callback Is executed when a form field is initialized and can e.g. be used to load a default value.
save_callback Is executed when a field is submitted and can e.g. be used to add an individual validation routine.

results matching ""

    No results matching ""