\Settings\CustomFields
Templating
Global Functions
Website
\Components\Website\Designs \Components\Website\Media \Components\Website\Pages \Components\Website\Pages\Forms \Components\Website\Posts \Components\Website\Posts\Categories
Customers
\Components\Customers\Contacts \Components\Customers\Contacts\Relationships \Components\Customers\Contacts\Relationships\Types \Components\Customers\Groups
Marketing
\Components\Marketing\EmailMarketing \Components\Marketing\Events \Components\Marketing\Events\Attendees \Components\Marketing\Events\Categories \Components\Marketing\Events\Locations \Components\Marketing\Events\Recurring \Components\Marketing\Events\Recurring\Rules \Components\Marketing\SMSMarketing
Commerce
\Components\Commerce\Carts \Components\Commerce\Carts\Current \Components\Commerce\Discounts \Components\Commerce\Products \Components\Commerce\Products\Brands \Components\Commerce\Products\Categories \Components\Commerce\Products\Inventory \Components\Commerce\RecurringSales\Items \Components\Commerce\Sales \Components\Commerce\Sales\Items \Components\Commerce\Sales\Receipts \Components\Commerce\Sales\Receipts\Allocations
Settings
\Components\Settings\Administrators \Components\Settings\CustomFields
METHODS
\Components\Settings\Domains
Other Apps
\Components\Website\Comments \Components\Commerce\Affiliates \Components\Commerce\Affiliates\Administrators \Components\Commerce\Affiliates\Commissions \Components\Commerce\Affiliates\Payments \Components\Commerce\RecurringSales \Components\Commerce\RecurringSales\StoredCards
Framework
\Framework\Caching \Framework\Data\Util \Framework\DOM\CurrentContext \Framework\HTML\Converters \Framework\HTTP\Cookies \Framework\HTTP\Redirection \Framework\HTTP\Request \Framework\HTTP\Session \Framework\HTTP\TabState \Framework\HTTP\UserAgent \Framework\I18N\CompanyTypes \Framework\I18N\Countries \Framework\I18N\Languages

CustomFields


Methods

Invoke via \Components\Settings\CustomFields::method()
Click a method name to copy it.
- ` \Iterator dbGetAllIterable($arrQuery) `
Returns the raw rows dbGetAll() would return as an iterator, without building them all into an array

The dbGetAll() counterpart of getAllIterable(), for scans over every stored row of a large table (eg: the site-wide content scans in \Framework\Developer\Refactoring). Rows are as stored - JSON fields are not decoded - and are not entity-cached. Because it bypasses getAll(), components that override getAll() are iterated; search queries and components overriding dbGetAll() are refused.
Parameters:
- $arrQuery
mixed
Return
Yields CustomFields
- ` bool delete($iCustomFieldId, $bDeleteMedia) `
Deletes a record from the database
Parameters:
- $iCustomFieldId
int
A record's custom_field_id
- $bDeleteMedia
mixed
Return
Returns true if record existed and was deleted, otherwise false
- ` array fieldsGetAll($bCached) `
Returns all the columns this component supports
Parameters:
- $bCached
mixed
Return
array
- ` array get($iCustomFieldId) `
Gets a record from the database
Parameters:
- $iCustomFieldId
int
A record's custom_field_id
Return
- ` array getAll($arrQuery) `
Return a set of records from the database
Parameters:
- $arrQuery
mixed
Return
Array of CustomFields
- ` \Iterator getAllIterable($arrQuery) `
Returns the entities getAll() would return as an iterator, without building them all into an array

For result sets too large to hold as arrays (eg: every recipient of a marketing send) - only the database driver's compact buffer of the result is held, a fraction of getAll()'s memory. Runs the same SQL as getAll(), and runs it now, as getAll() would; rows are decoded as you iterate.
Search queries are not supported, rows are not entity-cached, and components that override getAll() or dbGetAll() (eg: merging in defaults) are refused rather than iterated without their extra rows.
Parameters:
- $arrQuery
mixed
Return
Yields CustomFields
- ` array|null getByComponentAndField($strComponent, $strField) `
Returns a custom field from its component and field name
Parameters:
- $strComponent
mixed
- $strField
mixed
Return
array|null
- ` mixed getColumn($iCustomFieldId, $strColumn) `
Gets a single field from a record
Parameters:
- $iCustomFieldId
int
A record's custom_field_id
- $strColumn
mixed
Return
mixed
- ` int getCount($arrFilter) `
Returns the number of records in the database (matching the filter if specified)
Parameters:
- $arrFilter
mixed
Return
int
- ` string|null getForm($strComponent, $strField) `
Returns the form for a custom field
Parameters:
- $strComponent
mixed
- $strField
mixed
Return
string|null
- ` array|null getOptions($strComponent, $strField) `
If the custom field contains options, return them as an array
Parameters:
- $strComponent
mixed
- $strField
mixed
Return
array|null
- ` bool isHTMLType($arrCustomField) `
Returns whether a custom field stores HTML - i.e. its UI type definition carries the field_is_html flag (the formatted-text types)
Parameters:
- $arrCustomField
mixed
Return
bool
- ` string renderFieldValue($arrCustomField, $mValue, $iMaxLength) `
Renders a custom field value for display, handling serialized arrays and other field types
Parameters:
- $arrCustomField
mixed
- $mValue
mixed
- $iMaxLength
mixed
Return
The rendered field value
- ` string renderFieldValueHTML($arrCustomField, $mValue) `
Renders a custom field value as HTML that is safe to output raw ([?? ??]).

Formatted-text values pass through the allowlist bleacher again here, so a value that missed the save-time bleach (rows predating the type change, a stale worker cache) is still inert; every other type is HTML-encoded. The formatted-text types' default field_display uses this, and it is the only sanctioned way to render their HTML - never hand the value to logic:parse.
Parameters:
- $arrCustomField
mixed
- $mValue
mixed
Return
string
- ` string|int save($arrEntity) `
Saves a record into the database
Parameters:
- $arrEntity
mixed
Return
string|int
- ` void saveColumn($iCustomFieldId, $strColumn, $strValue) `
Saves a specific column of a row into a database
Parameters:
- $iCustomFieldId
int
A record's custom_field_id
- $strColumn
mixed
- $strValue
mixed
- ` array search($strSearch, $arrQuery) `
Performs a search
Parameters:
- $strSearch
mixed
- $arrQuery
mixed
Return
Array of CustomFields that match the search query.
- ` string uniquifyDataColumns($strForm, $strSuffix) `
Suffix all datacolumn's in the supplied form with the supplied string, allowing the custom field form to be unique when included in certain contexts such as
Automation conditions.
Parameters:
- $strForm
mixed
- $strSuffix
mixed
Return
The uniquified form.
- ` string uniquifyIDs($strForm, $strSuffix) `
Suffix all id's in the supplied form with the supplied Id, allowing the custom field form to be unique when included in certain contexts such as
Automation conditions.
Parameters:
- $strForm
mixed
- $strSuffix
mixed
Return
The uniquified form.

Database Fields

The following fields are used when retrieving and saving entities:
- `custom_field_id`
int (11)
- `custom_field_component`
string (255)
- `custom_field_table`
string (255)
- `custom_field_is_editable`
0 or 1
Default value: 1
- `field_id`
string (255)
- `field_label`
string (255)
- `field_description`
string (255)
- `field_ui_type`
string (255)
- `field_type`
string (31)
- `field_default_value`
string (31)
- `field_value_options`
string (65535)
- `field_form`
string (16777215)
- `field_is_mandatory`
0 or 1
- `field_is_searchable`
0 or 1
- `field_is_public`
0 or 1
- `field_is_shown_in_lists`
0 or 1
- `field_is_shown_in_checkout`
0 or 1
- `field_is_shown_in_manual_sales`
0 or 1
- `field_display`
string (16777215)
- `field_order`
int unsigned
- `field_data_retention_days`
int unsigned
- `field_data_retention_emails`
string (65535)

Examples

Custom Fields Combobox

Fill the values of a Combobox from a Custom Field

HTML Code:

<forms:row label="Select Relevant Industry Category"> <forms:combobox id="contact_industry" datasource="\Components\Settings\CustomFields::getOptions('\Components\Customers\Contacts', 'contact_industry')" as="industry" datatitle="$industry" datavalue="$industry" /> </forms:row>

Display a Custom Field Value using Logic Parse

HTML Code:

<logic:parse text="[? \Components\Settings\CustomFields::getForm('\Components\Customers\Contacts', 'contact_industry') ?]" />