Search code examples
extjs4aemday-cq

selection xtype listener unable to access multifield and multifield unable to fire the dialog.form.findfield


I have been working on disabling the content and ignoring data that is populated in a selection field that forms part of multifield that comes with CQ5 dialog

below is the code that is not working

    <medicineType
         jcr:primaryType="cq:Widget"
        fieldLabel="medicine Type : "
        name="./medicinetype"
        blankText="medicine Type"
        type="radio"
        xtype="selection">
        <options jcr:primaryType="cq:WidgetCollection">
          <inactive
            jcr:primaryType="nt:unstructured"
            text="medicine Lead"
            value="medicinelead" />
          <active
            jcr:primaryType="nt:unstructured"
            text="doctor Lead"
            value="doctorlead" />
        </options>
              <listeners jcr:primaryType="nt:unstructured" 
        selectionchanged="function(box,value){
        if(value == 'medicinelead'){
            var ans =     box.findParentByType('dialog').form.findField('./medicinedoctorset'); 
            ans.setDisabled(true);  
        ans.getEl().up('.x-form-item').setDisplayed(false);
            }
            "/>
    </medicineType>

    <medicinedoctorset
        fieldLabel="doctor cards"
        jcr:primaryType="cq:Widget"
        name="./medicinedoctorset"
        xtype="multifield">
        <fieldConfig
          jcr:primaryType="cq:Widget"
          type="select"
          options="/apps/doctor-api/components/medicineview/doctorcards.json"
          optionsRoot="doctorcards"
          optionsTextField="label"
          optionsValueField="id"
          xtype="selection" />
      </medicinedoctorset>

Solution

  • Not sure what exactly you are trying to do in the code, but it seems to me that you are trying to disable a particular field medicinedoctorset. Try adding id to the field you want to disable, get and disable the field as CQ.Ext.getCmp("idOfTheFieldToBeDisabled").setDisabled(true); Hope this helps.