Documentation

User fields settings factory

Description and methods

This extension contains fragments of interfaces and logic, necessary for managing user fields settings.

Main class for handling this extension

BX.UI.UserFieldFactory.Factory
Method Description Available from version
constructor(entityId: string, params: {}) Constructor.

Parameters:

  • entityId - entity string ID for which the fields are created
  • params - additional parameters, have the following structure:
    • menuId - identifier for field type creating selection menu;
    • types - array with additional field types to be added to standard list;
    • bindElement - DOM element, for passing to the object BX.Main.Popup for showing popup with list of fields;
    • configuratorClass - name of descendant class Configurator, to be used instead of standard class;
    • customTypesUrl - page address to be opened in slider upon clicking on Additional field type;
    • moduleId - module ID to be used in the model [link=11278086]UserField[/link].
getFieldTypes(): Array Method return array of field types with description.

Each element has the following structure:

  • name - string identifier [type](../../20_main/userfield/config/20_types.md);
  • title - type title;
  • description - description type;
  • defaultTitle - default title for creating new field.
getMenu(params: {}): CreationMenu Method returns object CreationMenu.
  • params - additional parameters for passing a popup in BX.Main.Popup with field type selection.
setConfiguratorClass(configuratorClassName: string|Function) Sets name for descendant class Configurator, to be used instead of standard class.
setCustomTypesUrl(customTypesUrl: string): this Sets page address to be opened in the slider upon clicking on Additional field type.
getConfigurator(params: {}): Configurator Returns object Configurator for setting up the field userField.

params has the following structure:

  • userField - object UserField, for which the settings form is displayed;
  • onSave - callback after saving the form;
  • onCancel - callback after clicking on cancel button.
createUserField(fieldType: string, fieldName: ?string): UserField Returns new object UserField.

Parameters:

  • fieldType - type string ID;
  • fieldName - name for new field. When not passed, generated automatically.
getDefaultLabel(fieldType: string): string Returns default field title (for new field).

Parameters:

  • fieldType - type string ID.
generateFieldName(): string Generates field code based on entity and current time.
onCustomTypeClick() Click handler for Additional field type.

Events

Event Description
namespace: BX.UI.UserFieldFactory.Factory
OnGetUserTypesEvent is thrown after initialising available types of user fields.

Handler receives array with list of types list, that can be updated.

onCreateFieldEvent is thrown after creating an object UserField in the method createUserField.

Handler can get the object userField.

onCreateCustomUserFieldEvent is thrown after creating an object бросается UserField via the full field settings form.

Handler can receive an object userField.



© «Bitrix24», 2001-2024