iliain / silverstripe-popup
Adds a field to quickly generate a CMS popup
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:silverstripe-vendormodule
Requires
- php: ^7 || ^8
- silverstripe/framework: ^4 || ^5
README
Adds a popup field to the CMS, to quickly build a popup form.
Thanks to sheadawson for his original Linkable module, I was able to mimic his use of entwine to set this up.
Installation (with composer)
composer require iliain/silverstripe-popup
Config
TODO
Usage
You can implement a PopupField like so:
// necessary config $customLink = '/PopupForms/form'; $customBodyJS = <<<JS // custom js goes here JS; // method A PopupField::create('PopupForm', 'I am a popup', $customLink, $customBodyJS); // method B PopupField::create('PopupForm', 'I am a popup') ->setFormURL($customLink) ->setFormCustomCode($customBodyJS);
You will need to provide your own URL to load the form HTML from, and JS to set what the popup will do/how it will submit. This will be inserted into the existing popup form code for you. Without it, the popup will open but fail to load any content/submit.
An example of the custom JS:
// On Button Click this.getDialog().on('click', 'button', function () { $(this).addClass('loading ui-state-disabled'); }); // On Submit this.getDialog().on('submit', 'form', function () { const options = {}; options.success = function (response) { const button = self.getDialog().find('button'); $(button).removeClass('loading ui-state-disabled'); }; $(this).ajaxSubmit(options); return false; });
See the docs for a full example
TODO
- Add more customisation functions?
- Test multiple popups active on the same page