Last active
December 16, 2015 19:19
-
-
Save stevedev/5484430 to your computer and use it in GitHub Desktop.
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 | |
Config::inst()->update( 'UserDefinedForm', 'extensions', array('UserDefinedFormExtension') ); |
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
(function($){ | |
$.entwine('ss', function($) { | |
$('.ss-gridfield .action.userform-export-csv').entwine({ | |
onclick: function(e){ | |
var self = this, btn = this.closest(':button'), grid = this.getGridField(); | |
var data = ''; | |
// Add current button | |
data += '&' + encodeURIComponent(btn.attr('name')) + '=' + encodeURIComponent(btn.val()); | |
// Include any GET parameters from the current URL, as the view state might depend on it. | |
// For example, a list prefiltered through external search criteria might be passed to GridField. | |
if(window.location.search) data = window.location.search.replace(/^\?/, '') + '&' + data; | |
window.location.href = $.path.makeUrlAbsolute(grid.data('url') + '?' + data, $('base').attr('href')); | |
return false; | |
} | |
}); | |
}); | |
}(jQuery)); |
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 | |
class UserDefinedFormExtension extends DataExtension { | |
public function getCMSFields() { | |
$fields = parent::getCMSFields(); | |
$this->extend( 'updateCMSFields', $fields ); | |
return $fields; | |
} | |
public function updateCMSFields( FieldList $fields ) { | |
Requirements::javascript('mysite/javascript/MFUserForm.js'); | |
$reports = $fields->fieldByName('Root.Submissions.Reports'); | |
$config = $reports->getConfig(); | |
// remove problematic export button | |
$config->removeComponentsByType( 'GridFieldExportButton' ); | |
// remove print button. Because it sucks too. | |
$config->removeComponentsByType( 'GridFieldPrintButton' ); | |
// add our own! | |
$config->addComponent( $export = new UserFormGridFieldExportButton() ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment