Documentation

UI editor usage

Parameters

Starting from ui 21.1200.0 module version you can create your own custom buttons next to standard "Save" and "Cancel" at the standard toolbar. Arbitrary actions can be assigned to buttons matching to corresponding actions, defined in class.php Component class support is implemented as a file /component_name/class.php. Class.php - is a reserved file name and this file is automatically connected when calling $APPLICATION->IncludeComponent()
Learn more...
of the component.

Future releases will also support actions, described in the ajax.php Query controller handler in the file ajax.php allows creating a lightweight ajax-query handler, by directly featuring the component logic.
Learn more...
.

The following bitrix:ui.form component parameters are responsible for additional actions:

ParameterStructureVersion
COMPONENT_AJAX_DATAADDITIONAL_ACTIONS - array, describing additional actions.
    Structure for array element:
  • ID - action ID.
  • ACTION - action name in component class.php (without suffix Action).
  • ACTION_TYPE - type of action. Possible values:
    • \Bitrix\UI\EntityEditor\Action::ACTION_TYPE_SAVE - action with saving (executing entity-editor logic, used with standard saving action - check for completed required fields, controller calls, etc.).
    • \Bitrix\UI\EntityEditor\Action::ACTION_TYPE_DIRECT - direct action (executed without saving logic).
available starting from ui 21.1200.0
CUSTOM_TOOL_PANEL_BUTTONSArray, describing additional toolbar buttons
    Array element structure:
  • ID - button identifier.
  • TEXT - button text.
  • ACTION_ID - action identifier, bound to a button click.
  • CLASS - extra CSS-classes for the button; for example, ui-btn-light-border.
available starting from ui 21.1200.0
TOOL_PANEL_BUTTONS_ORDERParameter, allowing to create order of buttons in the entity view and edit mode.
    Array structure:
  • VIEW - array with button IDs, displayed in the viewing mode.
  • EDIT - array with button IDs, displayed in the editing mode.

The following constants are used as IDs for standard buttons

\Bitrix\UI\EntityEditor\Action::DEFAULT_ACTION_BUTTON_ID for standard action (saving);

\Bitrix\UI\EntityEditor\Action::CANCEL_ACTION_BUTTON_ID for cancel button.

available starting from ui 21.1200.0

Examples

Example based on inventory management items.

Action description:

$this->arResult['FORM']['ADDITIONAL_ACTIONS'] = [
    [
        'ID' => 'SAVE_AND_CONDUCT',
        'ACTION' => 'saveAndConduct',
        'ACTION_TYPE' => UI\EntityEditor\Action::ACTION_TYPE_SAVE,
    ],
    [
        'ID' => 'CONDUCT',
        'ACTION' => 'conduct',
        'ACTION_TYPE' => UI\EntityEditor\Action::ACTION_TYPE_DIRECT,
    ],
    [
        'ID' => 'CANCEL_CONDUCT',
        'ACTION' => 'cancelConduct',
        'ACTION_TYPE' => UI\EntityEditor\Action::ACTION_TYPE_DIRECT,
    ],
];

Button description:

$this->arResult['FORM']['CUSTOM_TOOL_PANEL_BUTTONS'] = [
    [
        'ID' => 'SAVE_AND_CONDUCT',
        'TEXT' => Loc::getMessage('CATALOG_STORE_DOCUMENT_SAVE_AND_CONDUCT_BUTTON'),
        'ACTION_ID' => 'SAVE_AND_CONDUCT',
        'CLASS' => 'ui-btn-light-border',
    ],
    [
        'ID' => 'CONDUCT',
        'TEXT' => Loc::getMessage('CATALOG_STORE_DOCUMENT_CONDUCT_BUTTON'),
        'ACTION_ID' => 'CONDUCT',
        'CLASS' => 'ui-btn-light-border',
    ],
    [
        'ID' => 'CANCEL_CONDUCT',
        'TEXT' => Loc::getMessage('CATALOG_STORE_DOCUMENT_CANCEL_CONDUCT_BUTTON'),
        'ACTION_ID' => 'CANCEL_CONDUCT',
        'CLASS' => 'ui-btn-light-border',
    ],
];

Description for button order at the toolbar:

$viewButtons = $this->document && $this->document['STATUS'] === 'Y' ? ['CANCEL_CONDUCT'] : ['CONDUCT'];

$this->arResult['FORM']['TOOL_PANEL_BUTTONS_ORDER'] = [
    'VIEW' => $viewButtons,
    'EDIT' => [
        UI\EntityEditor\Action::DEFAULT_ACTION_BUTTON_ID, 'SAVE_AND_CONDUCT', UI\EntityEditor\Action::CANCEL_ACTION_BUTTON_ID,
    ],
];

Form data is not passed upon direct action; for example, use signed parameters for entity identification.

© «Bitrix24», 2001-2024
Up