>7.9 set readonly in javascript

Hi,

we are upgrading SugarCRM from 7.6 to 7.9 and setting readonly depending on values in Javascript does not work anymore. Cause the model is availble after rendering, setting a field to readonly has no effect when it's used in  this.on('render', ... or  this.model.once('sync', ...

We can't use PHP dependencies cause the readonly property should not be used by the API. This is an example code:

handleFieldProperties: function() {
     var type = this.model.get('list_type');         
     _.each(this.meta.panels, function(panel) {
        _.each(panel.fields, function(field, index, list){
            if (_.isString(field)) {
                field = {name: field};
            }
            if (type == 'unique_campaign' && field.name == 'description') {
                field.readonly = true;
                field.required = false;
                list[index] = field;
            }
        });
    }, this);
},

Has someone a solutions do set these fields to readonly and required = false?

Best regards

Harald Kampen##

Parents
  • Hi Harald Kampen 

    Why to do that through javascript instead of Dependency ReadOnly?

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi André,

    we have different requirements what's allowed by UI and by API. When I use dependencies, the API call, in this case, cannot change the prospect list to a different type, which is required in some cases.

    Regards

  • Hi André,

    the dependency action ReadOnly simply sets the fields to read only with some Javascript in the view and has no effect on API calls. We use this, but it's not future save, cause ReadOnly is not defined to be used only in the UI.

    it would be great to have the abilty again to set read-only and  required in Javascripts.

    <?php
    $dependencies['ProspectLists']['UniqueCampaign'] = array(
        'hooks' => array("edit"),
        'trigger' => 'true',
        'triggerFields' => array('list_type'),
        'onload' => true,
        'actions' => array(
            array(
                'name' => 'ReadOnly',
                'params' => array(
                    'target' => 'list_type',
                    'value' => 'equal($list_type,"unique_campaign")',
                ),
            ),
            array(
                'name' => 'ReadOnly',
                'params' => array(
                    'target' => 'name',
                    'value' => 'equal($list_type,"unique_campaign")',
                ),
            ),
            array(
                'name' => 'ReadOnly',
                'params' => array(
                    'target' => 'campaign_group',
                    'value' => 'equal($list_type,"unique_campaign")',
                ),
            ),
            array(
                'name' => 'ReadOnly',
                'params' => array(
                    'target' => 'primary_campaign_group',
                    'value' => 'equal($list_type,"unique_campaign")',
                ),
            ),
        ),
    );

    Regards

    Harald

Reply
  • Hi André,

    the dependency action ReadOnly simply sets the fields to read only with some Javascript in the view and has no effect on API calls. We use this, but it's not future save, cause ReadOnly is not defined to be used only in the UI.

    it would be great to have the abilty again to set read-only and  required in Javascripts.

    <?php
    $dependencies['ProspectLists']['UniqueCampaign'] = array(
        'hooks' => array("edit"),
        'trigger' => 'true',
        'triggerFields' => array('list_type'),
        'onload' => true,
        'actions' => array(
            array(
                'name' => 'ReadOnly',
                'params' => array(
                    'target' => 'list_type',
                    'value' => 'equal($list_type,"unique_campaign")',
                ),
            ),
            array(
                'name' => 'ReadOnly',
                'params' => array(
                    'target' => 'name',
                    'value' => 'equal($list_type,"unique_campaign")',
                ),
            ),
            array(
                'name' => 'ReadOnly',
                'params' => array(
                    'target' => 'campaign_group',
                    'value' => 'equal($list_type,"unique_campaign")',
                ),
            ),
            array(
                'name' => 'ReadOnly',
                'params' => array(
                    'target' => 'primary_campaign_group',
                    'value' => 'equal($list_type,"unique_campaign")',
                ),
            ),
        ),
    );

    Regards

    Harald

Children