Hide Panel in EditView

Hello Everyone,

Anyone has any idea how to hide the panel depends on the value of radio field or dropdown field? Mine wasn`t working, this is what I want to achieve if you select the commercial radio field a certain panel will hide.

First I created a Custom.tpl in my Account Module. Check my codes below

<script>
    {literal}
    //Account Type
    var radioChange = "input[name='customer_classification_c']";
    YAHOO.util.Event.onDOMReady(function () {
        disabledAccountType();

        YAHOO.util.Event.addListener(YAHOO.util.Selector.query(radioChange), "change", function () {
            disabledAccountType();
        });

        function disabledAccountType() {
            if ($('input[name="customer_classification_c"]:checked').val() == 'Commercial') {
                $('#customer_classification_type').attr('disabled',false);
                $('#name').attr('disabled',false);

                $('#first_name').attr('required',false);
                $('#middle_name').attr('required',false);
                $('#last_name').attr('required',false);
                $('#lbl_editview_panel5').hide();
            } else {
                $('#customer_classification_type').attr('disabled',true);
                $('#name').attr('disabled',true);

                $('#first_name').attr('required',true);
                $('#middle_name').attr('required',true);
                $('#last_name').attr('required',true);
                $('#lbl_editview_panel5').show();
            }
        }
    });
{/literal}
</script>

Additional: It is possible also to remove the require attribute of the First Name, Middle Name and Last Name if the whole panel is hidden. By the way in vardefs I set those three fields as required.

Didi you ever get this to work? I’m trying the exact same thing RN. Looking for answers too :wink:

Hi Yeah, I was able to hide this one.

//To hide
$('div[id="detailpanel_0"]').parents('.panel-default').addClass('hidden');
//To Show
$('div[id="detailpanel_0"]').parents('.panel-default').removeClass('hidden');
1 Like

Thanks :+1:
Found this, https://www.youtube.com/watch?v=TJy8t-6Rzk0&ab_channel=suiteCRMv.7tutorials
it’s helping lots

Ow, that’s nice. I used another approach to hiding the panel. But it is good to hear that you were able to resolve your concern…

1 Like