Documentation

UF-field class

All UF classes must be descendants to the class BaseType and located at <modulename>/lib/usefield/types/<classname>/ of corresponding module, for example /main/lib/userfield/types/stringtype.


Required constants:
  • USER_TYPE_ID - user type unique identifier;
  • RENDER_COMPONENT - name of component to be used for rendering.

Required methods:
  • getDescription - method must return an associative array with user-friendly field type name (DESCRIPTION) and base type (BASE_TYPE);
  • getDbColumnType - method returns MySQL column type that will store single field value. Multiple fields are always stored as text.

Other methods:
  • prepareSettings - prepares and returns array of settings for user type instance;
  • getFilterData - returns array to be used in the new filter in admin section;
  • checkFields - validator, returns an associative array ['id'=> 'FIELD_NAME', 'text' => 'erorr message'] or an empty array with no validation errors;
  • onSearchIndex - returns a search field value;
  • onBeforeSave- called before saving UF field.
  • getDefaultValue This method is available from version 20.5.500.

    Method parameters:
    ParameterDescription
    $userFieldArray with user field metadata. Can be retrieved via the method GetUserFields of class CUserTypeManager.
    $additionalParametersArray, containing necessary settings depending on the invoked template. Specifically, this array passes the following elements:
    • mode - component template name;
    • mediaType - template page name (at preset, .default, or mobile). Empty value is equivalent to .default.
    * with $additionalParameters can be an empty array.
    - returns user field value, set by default.

© «Bitrix24», 2001-2024
Up