Adding config fields to a dashlet

Hello,

I'm trying to modify a custom dashlet in an Enterprise 7.8.2.1 Sugar instance, adding two fields to the dashlet config (it has none at this time). These fields should be used to filter the info the dashlet is showing.

This is my dashlet metadata file:

<?php
$viewdefs['base']['view']['indicadores-dashlet'] = array(
    'dashlets' => array(
        array(
            'label' => 'Indicadores semanales',
            'description' => 'Indicadores semanales',
            'config' => array(
            ),
            'preview' => array(
            ),
            'filter' => array(
                'module' => array(
                    'Contacts',
                ),
                'view' => array(
                    'record',
                )
            )
        ),
    ),
);

?>

And this is the same file after I try to add a config field:

<?php
$viewdefs['base']['view']['indicadores-dashlet'] = array(
    'dashlets' => array(
        array(
            'label' => 'Indicadores semanales',
            'description' => 'Indicadores semanales',
            'config' => array(
            ),
            'preview' => array(
            ),
            'filter' => array(
                'module' => array(
                    'Contacts',
                ),
                'view' => array(
                    'record',
                )
            )
        ),
    ),
    'config' => array(
        'fields' => array(
            array(
                'name' => 'ramos_c',
                'label' => 'LBL_RAMOS_C',
                'type' => 'enum',
                'isMultiSelect' => true,
                'options' => array(
                    'value1' => 'key1',
                    'value2' => 'key2'
                )
            ),
        ),
    ),
);

?>

I've tried modifying the field attributes, trying to make it a text field and so, with no luck. Whatever I do, when I run a Quick Repair and Rebuild and try to edit the dashlet its config panel remains blank.

Does anyone know if I'm missing something? I would appreciate any help on this.

Thanks,

Rodrigo Morchio

  • Well, I was able to achieve what I wanted to do, by looking at the code of some out-of-the-box dashlets. This is my final code, for anyone that may be having the same problem:

    <?php
    $viewdefs['base']['view']['indicadores-dashlet'] = array(
        'dashlets' => array(
            array(
                'label' => 'Indicadores semanales',
                'description' => 'Indicadores semanales',
                'config' => array(
                ),
                'preview' => array(
                ),
                'filter' => array(
                    'module' => array(
                        'Contacts',
                    ),
                    'view' => array(
                        'record',
                    )
                )
            ),
        ),
        'panels' => array(
            array(
                'name' => 'panel_body',
                'columns' => 2,
                'labelsOnTop' => true,
                'placeholders' => true,
                'fields' => array(
                    array(
                        'name' => 'ramo',
                        'label' => 'Ramo',
                        'type' => 'enum',
                        'isMultiSelect' => true,
                        'searchBarThreshold' => -1,
                        'options' => 'ramos_list'
                    ),
                    array(
                        'name' => 'negocio',
                        'label' => 'Negocio',
                        'type' => 'enum',
                        'searchBarThreshold' => -1,
                        'options' => 'negocio_c_list'
                    ),
                ),
            ),
        ),
    );

    ?>

    The values of these fields are accesible from the dashlet controler (.js file) with this.settings.get("ramo") and this.settings.get("negocio").

    Regards,

    Rodrigo Morchio