Documentation

Library iblock.field-selector

Description and example

Library iblock.field-selector is designed to be used in custom properties for iblock and binding UF-fields for Information blocks module entities.

Library allows using TagSelector in the form or grid input fields. The values be integers or strings.

Use:

	\Bitrix\Main\Loader::includeModule('iblock');
	
	\Bitrix\Main\UI\Extension::load('iblock.field-selector');
	
	$containerId = 'my_element'; // container's ID dom for TagSelector
	
	$values = 100; // current value
	
	$config = \Bitrix\Main\Web\Json::encode([
		'containerId' => $containerId,
		'fieldName' => 'myfield',
		'multiple' => false,
		'collectionType' => 'int',
		'selectedItems' => $values,
		'iblockId' => 41,
		'userType' => \Bitrix\Iblock\PropertyTable::USER_TYPE_ELEMENT_AUTOCOMPLETE,
		'entityId' => \Bitrix\Iblock\Integration\UI\EntitySelector\IblockPropertyElementProvider::ENTITY_ID,
	]);
	
	return <<<HTML
		<div id="$containerId"></div>
		<script>
			(function() {
				const selector = new BX.Iblock.FieldSelector($config);
				selector.render();
			})();
		</script>
HTML;

The example above has a set of items, belonging to iblock with ID = 41 for single (multiple) "Link-to-element autocomplete text box" (userType) property type. Current value (selectedItems) – 100. Value type is passed in the key collectionType and can have values int or string.

Data provider ID is specified in the key entityId.


Attention! You can work only with a single provider at a time. This is due to specified of library design.

DOM-element for selector container must be rendered manually.

Input parameters

ParameterTypeDescription
containerId *stringPage DOM-element, containing selector.
fieldName *stringForm field name to record the result. You must add [] to field name for selector with multiple selection.
multipleboolSingular or multiple property/field. Default value: false.
collectionTypestringProperty/field property type. Possible values – int or string. Default value: int.

Attention! Current values for selector must be converted to this type.

selectedItems *
  • for singular values: string, int or array with single value;
  • for multiple values – always array with values
Current values for property/field.
iblockId *intIblock ID from which data is fetched. If property/field is not associated to a specific iblock, you must pass null.
userTypestringCustom property/field ID.
entityId *stringData provider ID. Standard providers are available:
  • \Bitrix\Iblock\Integration\UI\EntitySelector\IblockPropertyE­lementProvider::ENTITY_ID – for selecting iblock elements;
  • \Bitrix\Iblock\Integration\UI\EntitySelector\IblockPropertyS­ectionProvider::ENTITY_ID – for selecting iblock sections;
  • \Bitrix\Highloadblock\Integration\UI\EntitySelector\ElementP­rovider::ENTITY_ID – for selecting highload-block elements.
searchMessagesobjectSearch window messages in case of empty result. Object contains fields:
  • title – window title, string;
  • subtitle – clarification text, string.
changeEventsarraysList with js events, called after value updates in selector.

* – required parameters.


© «Bitrix24», 2001-2025
Up