-
-
Save pepebe/ba5974b7367f5a35d0d3a7f31aa14aa5 to your computer and use it in GitHub Desktop.
Plugin to add a "created by" field on a MODX Revolution resource form, listening on the "OnDocFormPrerender" event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Sample plugin to add a "created by" field on a resource form | |
| * | |
| * @var modX $modx | |
| * @var array $scriptProperties | |
| * | |
| * @event OnDocFormPrerender | |
| */ | |
| $modx->controller->addHtml(<<<HTML | |
| <script> | |
| // We are targeting the right column in the settings tab | |
| Ext.ComponentMgr.onAvailable('modx-page-settings-right', function(right) { | |
| right.on('beforerender', function() { | |
| // page is a reference to the whole form panel | |
| var page = Ext.getCmp('modx-panel-resource') | |
| // record is a reference to our resource fields | |
| ,record = page.record | |
| ; | |
| // Let's add our new field at the bottom of the column | |
| right.add({ | |
| xtype: 'modx-combo-user' | |
| ,name: 'createdby' | |
| ,hiddenName: 'createdby' | |
| ,value: record.createdby | |
| ,anchor: '100%' | |
| ,layout: 'anchor' | |
| ,fieldLabel: _('resource_createdby') | |
| }); | |
| }) | |
| }); | |
| </script> | |
| HTML | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment