CoolCMS API

ExternalConnectionFormTrait

Forms of third-party connections, one form per installed connection.

A component factory builds the forms by row id (connectionForm-<id>). The user cannot change the number of rows: connections are created by installation (SQL), not in the admin.

Form fields derive from the connection type registry (getFields()):

  • Text gives addText, Number a numeric field, Bool addCheckbox,
  • Secret gives addPassword, which never prints the stored value; an empty submit keeps the stored value, a filled one overwrites it, a checked clear_<field> deletes it.

IMPORTANT: required fields are validated only for an enabled connection; a disabled one may stay unfinished.

IMPORTANT: field names carry a prefix (field_, clear_) so that a type field can never collide with enabled or other form controls.

Groups (ConnectionTypeInterface::getGroup()): enabling a connection disables the other enabled connections of the same group, as they are alternatives (e.g. reCAPTCHA v2 and v3). One Api operation in one DB transaction (saveExclusive) saves the connection and disables the alternatives; on failure nothing changes.

Table of Contents

Constants

CLEAR_PREFIX  : string = 'clear_'
FIELD_PREFIX  : string = 'field_'
SESSION_OPENED  : string = 'opened'
SESSION_SECTION  : string = 'admin.externalConnections'
Session section + key remembering which card was just saved (consumed on next render).

Methods

createComponentConnectionForm()  : Multiplier<string|int, Form>
addConnectionField()  : void
buildConnectionTitles()  : array<int, string>
connectionControl()  : BaseControl|null
createConnectionForm()  : Form
isConnectionSecretStored()  : bool
saveConnectionForm()  : bool
setConnectionFormDefaults()  : void
validateConnectionForm()  : void
Validates required fields only for an enabled connection.

Constants

SESSION_SECTION

Session section + key remembering which card was just saved (consumed on next render).

private string SESSION_SECTION = 'admin.externalConnections'

Methods

buildConnectionTitles()

private buildConnectionTitles(mixed $types) : array<int, string>
Parameters
$types : mixed

type codes returned by the Api operation

Return values
array<int, string> —

translated connection titles

connectionControl()

private connectionControl(Form $form, string $name) : BaseControl|null
Parameters
$form : Form
$name : string
Return values
BaseControl|null

saveConnectionForm()

private saveConnectionForm(int $id, ArrayHash<string|int, mixed> $values) : bool
Parameters
$id : int
$values : ArrayHash<string|int, mixed>
Return values
bool
On this page

Search results