Created
March 27, 2014 19:20
-
-
Save matthewpoer/9815907 to your computer and use it in GitHub Desktop.
When installing a package, maybe you need to add some buttons to a modules detail or edit view? Maybe you'd like to add your button without, you know, wiping out existing customization to the system's layout? Here's how you'd do that with a post_install script. Simply place this within your module's directory at /scripts/post_install.php, zip it…
This file contains 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 | |
function post_install(){ | |
// define our new button that will copy into detailviewdefs.php | |
$button = array( | |
'customCode' => '<input type=\'button\' title=\'Create Payments\' onclick=\'this.form.action.value=\\\'CreatePayments\\\';\' />', | |
'sugar_html' => array( | |
'type' => 'submit', | |
'value' => 'Create Payments', | |
'htmlOptions' => array( | |
'class' => 'button', | |
'id' => 'CreatePaymentsButton', | |
'title' => 'Create Payments', | |
'onclick' => 'this.form.action.value=\'CreatePayments\';', | |
), | |
), | |
); | |
// load and use ParserFactory to add the button to the current layout | |
require_once('modules/ModuleBuilder/parsers/ParserFactory.php'); | |
$parser = ParserFactory::getParser('detailview', 'Contacts'); | |
array_push($parser->_viewdefs['templateMeta']['form']['buttons'], $button); | |
$parser->handleSave(false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment