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:
Parameter | Structure | Version |
---|---|---|
COMPONENT_AJAX_DATA | ADDITIONAL_ACTIONS - array, describing additional actions.
| available starting from ui 21.1200.0 |
CUSTOM_TOOL_PANEL_BUTTONS | Array, describing additional toolbar buttons
| available starting from ui 21.1200.0 |
TOOL_PANEL_BUTTONS_ORDER | Parameter, allowing to create order of buttons in the entity view and edit mode.
The following constants are used as IDs for standard buttons
| 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.