Documentation

Components for rendering user fields

Description

New API is available for user field controls rendering starting from the main module version 20.0.800.

All components and parameters can be called in the same manner; only user field type is changed.

All components contain templates for desktop and mobile apps and support options to modify control's external appearance via standard template mechanism.

The physical structure path is located at the folder /bitrix/components/bitrix/[component_name].

List of components

ComponentDescription
main.field.booleanRenders boolean (yes/no) user fields.
main.field.dateRenders date (date only) user fields.
main.field.datetimeRenders datetime (date with time) user fields.
main.field.doubleRenders double (numeric) user field.
main.field.enumRenders enum (list) user fields.
main.field.fileRenders file user fields.
main.field.integerRenders integer user fields.
main.field.stringRenders string user fields.
main.field.stringformattedRenders stringformatted type user fields.
main.field.urlRenders url (adderess) user fields.

Parameters

ParameterDescription
$userFieldArray of user field meta information. Can be fetched by the method GetUserFields of class CUserTypeManager.
$additionalParametersArray contains necessary settings depending on the template, used for control element's display. Specifically, this array passes the following elements:
  • mode - component template name;
  • mediaType - template page name at the current moment or .default, mobile. Empty value equals to .default.

Example of calling the component main.field.string

<?
$APPLICATION->IncludeComponent(
            'bitrix:main.field.string',
            '',
            [
                'userField' => $userField,
                'additionalParameters' => $additionalParameters,
            ]
        );
?>

Additional data

[link=11528494]Universal API[/link] can be used as well:

$renderer = new \Bitrix\Main\UserField\Renderer($userField, $additionalParameters);
return $renderer->render();

© «Bitrix24», 2001-2022
Up