{"id":15282349,"url":"https://github.com/devgroup-ru/yii2-admin-modals","last_synced_at":"2026-04-20T10:02:52.504Z","repository":{"id":62502724,"uuid":"83572839","full_name":"DevGroup-ru/yii2-admin-modals","owner":"DevGroup-ru","description":"Display your admin actions in bootstrap modals with frames and callbacks","archived":false,"fork":false,"pushed_at":"2017-06-02T13:17:48.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T16:45:00.326Z","etag":null,"topics":["admin","bootstrap","modals","yii2","yii2-admin","yii2-backend","yii2-bootstrap-modal","yii2-extension"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevGroup-ru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-01T15:56:51.000Z","updated_at":"2019-03-20T05:44:48.000Z","dependencies_parsed_at":"2022-11-02T12:16:04.402Z","dependency_job_id":null,"html_url":"https://github.com/DevGroup-ru/yii2-admin-modals","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DevGroup-ru/yii2-admin-modals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevGroup-ru%2Fyii2-admin-modals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevGroup-ru%2Fyii2-admin-modals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevGroup-ru%2Fyii2-admin-modals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevGroup-ru%2Fyii2-admin-modals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevGroup-ru","download_url":"https://codeload.github.com/DevGroup-ru/yii2-admin-modals/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevGroup-ru%2Fyii2-admin-modals/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32042294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admin","bootstrap","modals","yii2","yii2-admin","yii2-backend","yii2-bootstrap-modal","yii2-extension"],"created_at":"2024-09-30T14:25:15.072Z","updated_at":"2026-04-20T10:02:52.461Z","avatar_url":"https://github.com/DevGroup-ru.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Yii2 Admin Modals\n=================\nDisplay your admin actions in bootstrap modals with frames and callbacks.\n\n**Current status:** Work in progress.\n\nInstallation\n------------\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\nphp composer.phar require --prefer-dist devgroup/yii2-admin-modals \"*\"\n```\n\nor add\n\n```\n\"devgroup/yii2-admin-modals\": \"*\"\n```\n\nto the require section of your `composer.json` file.\n\n\nUsage\n-----\n\n### 1. Configure application\n\nAdd `DevGroup\\AdminModals\\components\\AdminModals` component with component id `adminModals`.\n\nModify your main web application config:\n\n```php\nreturn [\n    // your app config here\n    // ...\n    \n    'components' =\u003e [\n        'adminModals' =\u003e [\n            'class' =\u003e 'DevGroup\\AdminModals\\components\\AdminModals',\n            'layoutFile' =\u003e '@app/actions/views/empty-layout',\n        ],\n        // your other app components\n    ],\n];\n```\n\n`AdminModals` components has the following params:\n\n- **layoutFile**_(required)_ - The path to simplified layout file without your headers, footers, containers etc. This layout is used when your action is rendered inside modal's frame.\n- **magicParamKey** and **uniqueParamKey** - Names of GET parameters that are used for communicating between JS part and yii2 backend.\n\n### 2. Add `admin-modals` action\n\nAdmin-modals action is used for displaying simple empty page inside modal's frame during loading the needed route.\n\nYou can show loader spinner there.\n \nBy default JS part of yii2-admin-modals will load '/site/admin-modal'. That could be configured later.\n\nFor adding action modify your Controller actions() function:\n\n```php\n    public function actions()\n    {\n        return [\n            // other actions here...\n            \n            'admin-modal' =\u003e [\n                'class' =\u003e DevGroup\\AdminModals\\actions\\EmptyPageAction::class,\n                'viewFile' =\u003e '@DevGroup/AdminModals/views/admin-modal',\n                'layoutFile' =\u003e '@app/actions/views/empty-layout',\n            ]\n        ];\n    }\n```\n\n`EmptyPageAction` takes the following params:\n\n- **layoutFile** - The same as in `AdminModalsBehavior` but is not required. If not set - the default controller layout will be used.\n- **viewFile** - The view file location for empty page. By default sample view is used. The only requirement to this view file is to include form tag with `admin-modal__frame-form` class that would be used for loading actions with POST method.\n\n### 3. Frontend configuration\n\nAt first you need to add dependency to `DevGroup\\AdminModals\\assets\\AdminModalsBundle` in you main application AssetBundle:\n\n```php\n\nclass AppAsset extends AssetBundle\n{\n    // your stuff here\n\n    public $depends = [\n        // add dependency\n        DevGroup\\AdminModals\\assets\\AdminModalsBundle::class,\n    ];\n}\n\n```\n\nIf you need to configure JS-part of yii2-admin-modals - add javascript object before AdminModalsBundle loads(for example after opening body tag):\n\n```js\nwindow.AdminModalsSettings = {\n    modalActionSelector: '.admin-modal-trigger',\n    dataAttribute: 'adminModals',\n    adminModalPageUrl: '/site/admin-modal',\n    adminModalFrameFormSelector: '.admin-modal__frame-form',\n    magicParamKey: '__admin_modals',\n    adminModalsUniqueParamKey: '__admin-modals__unique-id'\n}\n```\n\n### 4. Use your modals\n\nAll links and buttons with `admin-modal-trigger` class assigned will automatically call opening modal windows instead of direct action performing.\n\nExample code:\n\n```html\n\u003ca href=\"/admin/user/edit?id=1\" class=\"btn btn-primary modal-test admin-modal-trigger\"\u003e\n    Open user #1 edit form in modal!\n\u003c/a\u003e\n```\n\n\n### How to manually trigger modal?\n\nAn example for showing confirmation on deletion of jstree node:\n\n```js\nfunction confirmDelete(node) {\n  AdminModals.modalOpen({\n    url: '/category/delete',\n    data: {\n      id: $(node.reference[0]).data('id')\n    },\n    method: 'GET',\n    closeCallback: function() {\n      alert('Thank you!');\n    }\n  });\n  return false;\n}\n```\n\nThat will display `/category/delete?id=###` in modal.\n\n\n### Helpers\n\n#### JsTreeHelper\n\nA helper for jstree `DevGroup\\AdminModals\\helpers\\JsTreeHelper` has the following static functions:\n\n- **modalOpen**_($route, $method = 'GET', $attributesMapping = ['id' =\u003e 'id'])_ - Used for opening modals on context-menu actions. \n    Attributes mappings describe additional data params to be added to request. \n    Key is the name of target param, value is the key of data attribute of jstree node which stores target value.\n\n## TODO\n\n- [x] Implement callback\n- [ ] Add more events in $ style\n- [ ] Document all options\n- [ ] Describe the main concept(iframe -\u003e location|form.submit -\u003e storage events -\u003e extract buttons ...)\n- [ ] Test app\n    - [ ] Simple modal demo\n    - [ ] GridView actions demo (test with pjax too)\n    - [ ] Deploy live version\n    - [ ] Codeception functional tests\n    - [ ] Screenshots and demo-video\n- [ ] Add cool badges\n- [ ] Remove console.log\n- [ ] ???\n- [ ] PROFIT!!! _and spread the word_","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevgroup-ru%2Fyii2-admin-modals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevgroup-ru%2Fyii2-admin-modals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevgroup-ru%2Fyii2-admin-modals/lists"}