Adminer
Unit BlackFox\Adminer accepts as a parameter an object inherited from SCRUD and provides full control over the table:
- View as a table with possibilities of: filtering, sorting, page navigation, changing columns and filters display and order.
- Forms for creating and updating elements
- Ability to delete elements
\BlackFox\Adminer::Run(['SCRUD' => Docs\Feedback::I()]);
Methods
Public methods are actions
Name | Parameters | Description |
---|---|---|
Section | $FILTER = [], $PAGE = 1, $SORT = ['ID' => 'DESC'], $FIELDS = ['*@@'] | Displays the table |
GetDefaultValues | Returns the default dictionary | |
GetBackLink | Returns a link to the previous page | |
CreateForm | $FILTER = [], $FIELDS = [] | Displays a form to create new item |
UpdateForm | $ID = null, $FIELDS = [] | Displays the edit form of an existing element |
Create | $FIELDS = [], $REDIRECT = 'Stay' | Create element |
Update | $ID, $FIELDS = [], $REDIRECT = 'Stay' | Edit element |
GetLinkForRedirect | $ID, $REDIRECT | Returns a link to the next page |
Delete | $ID | Deletes element(s) |
GetPages | $total, $current, $limit | Returns an array used to form pagination |
ControlUrl | Clears GET request from empty values | |
SanitizeUrl | $url | Converts the GET request to a human-readable form |
LoadTableSettings | Loads table settings | |
SaveTableSettings | $filters = [], $fields = [] | Saves table settings |
GetTabsOfCreate | Returns an array of tabs of the element creation form | |
GetTabsOfUpdate | Returns an array of tabs of the edit element form | |
SearchOuter | $code, $search, $page = 1 | looks For suitable values for the external element |
Views
Name | Description |
---|---|
element | a set of tabs that include a form for creating/editing an element |
element_tab_main | tab is for creating / editing the item |
element_head | the header from the form of creating / editing the item |
element_foot | the footer from the form of creating / editing the item |
element_bottom_buttons | Buttons "Save", "Confirm", "Cancel", "Delete" |
element_tab_external | Tab for table of related elements (can be multiple) |
filter | filter |
section | section: filter + element table |
pager | page navigation |
section_settings | section display settings |
section_settings_list | section display settings: list of fields |
Example of adding a view
Suppose you want to add an additional tab to the
edit form of the element on which to place the form for the new action.
To do this, create a descendant unit from
Override
namespace BlackFox; class AdminerUsers extends Adminer { // ... public function GetTabsOfUpdate() { return parent::GetTabsOfUpdate() + [ 'actions' => [ 'NAME' => T([ 'en' => 'Actions', 'ru' => 'Действия', ]), 'VIEW' => 'element_tab_actions', ], ]; } }
Create view
/** @var \BlackFox\Adminer $this */ ?> /** @var array $RESULT */ ?> <form method="post"> <button type="submit" name="ACTION" value="Login" class="btn btn-info" > <?= T([ 'en' => 'Log in with this user', 'ru' => 'Авторизоваться под этим пользователем', ]) ?> </button> </form>
Example of view inheritance
Suppose that you want to rewrite the form of creating of element.
To do this, create a descendant unit from
<?php /** @var \BlackFox\Adminer $this */ ?> <?php /** @var array $RESULT */ ?> <? if ($RESULT['MODE'] <> 'Create'): ?> <? require $this->TemplateParentPath(); ?> <? else: ?> <form method="post" enctype="multipart/form-data"> <!-- new form for update --> </form> <? endif; ?>
the method