include/Smarty/plugins/function.sugar_button.php

Show: inherited
    Table of Contents

    Smarty plugin

    Author
    Collin Lee {clee@sugarcrm.com}  
    Package
    Smarty  
    Subpackage
    plugins This is a Smarty plugin to handle the creation of HTML form buttons under the metat-data framework. The buttons may be defined using either the set of built-in buttons or custom code. For example, to add the 'SAVE' and 'CANCEL' buttons to the editviewdefs.php meta-data file, you will create a key/value pair where the key is of value 'form' and value is another array with a 'buttons' key. ... $viewdefs['Accounts']['EditView'] = array( 'templateMeta' => array( 'form' => array('buttons'=>array('SAVE','CANCEL')), ... The supported types are: CANCEL, DELETE, DUPLICATE, EDIT, FIND_DUPLICATES and SAVE. If you need to create a custom button or the button is very specific to the module and not provided as a supported type, then you'll need to use custom code. Instead of providing the key, you'll have to create an array with a 'customCode' key. ... $viewdefs['Accounts']['EditView'] = array( 'templateMeta' => array( 'form' => array('buttons'=>array('SAVE', array('customCode'=>'') )), ... Please note that you should ensure that your customCode is generic in the sense that there are no instance specific values created because it will cause failures should other instances also use the button's code. The key to remember is that we are rendering a generic template for each module's view and, as such, the meta-data definition should also be generic enough to support variable instance values for the module. In our examples, the resulting metatdata definition is passed to EditView's header.tpl file and the Smarty plugin (this file) is invoked as follows: {{sugar_button module='{{$module}}' id='{{$form.buttons[$id]}}' view='EditView'}}  

    Functions

    functionextractHiddenInputs( array $dom_tree = array() ) : void

    Bug#51862: Extract hidden field form the original dom structure

    Parameters
    Name Type Description
    $dom_tree array
    • Cascade array form generated by SugarHtml::parseHtmlTag
    functionreplaceFormClick( array $dom_tree = array(), string $js_form = '', bool $hidden_field_exists = false ) : array

    Bug#51862: Reproduce the JS onclick for upgraded instances

    Parameters
    Name Type Description
    $dom_tree array
    • Cascade array form generated by SugarHtml::parseHtmlTag
    $js_form string
    • JS getter to assign _form object by ID
    $hidden_field_exists bool
    • whether the selected element contains hidden fields or not
    Returns
    Type Description
    array - two boolean variables. $set_submit - whether the replace operation is excuted or not $is_hidden_field - where current attributes contains the key "hidden" or not
    functionsmarty_function_sugar_button( \$params $params, \$smarty $smarty ) : void

    smarty_function_sugar_button This is the constructor for the Smarty plugin.

    Parameters
    Name Type Description
    $params \$params

    The runtime Smarty key/value arguments

    $smarty \$smarty

    The reference to the Smarty object used in this invocation

    Documentation was generated by DocBlox 0.18.1.