1

I have a Checkbox which dynamically rerenders a field (field is not shown if checkbox is false). Here is the code:

<apex:inputField id="IsPaidPd" value="{!Consultant_Request__c.Is_Paid_PD__c}" required="false">
                 <apex:actionSupport event="onchange" rerender="PurchaseOrderNumber_Wrapper" />
            </apex:inputField>  

            <apex:pageBlockSectionItem >
            <apex:outputPanel id="PurchaseOrderNumber_Wrapper">
            <apex:outputLabel value="Purchase Order Number" for="PurchaseOrderNumber" rendered="{!Consultant_Request__c.Is_Paid_PD__c}"/>
                  <apex:inputField id="PurchaseOrderNumber" value="{!Consultant_Request__c.Purchase_Order_Number__c}" required="false" rendered="{!Consultant_Request__c.Is_Paid_PD__c}"/>
            </apex:outputPanel>
            </apex:pageBlockSectionItem>

Which is mostly working fine. However, if any 'required' fields are not filled out when I try to check/uncheck the checkbox 'IsPaidPd', the rerender action is never fired and the subsequent fields are not updated. This is not very intuitive and a user might think something is broken before realizing all those fields must be filled out until this functionality will work correctly. As you can see, I am doing targeted rerendering which hasn't solved anything.

1
  • One alternative is to not make your fields required "client" side, but check before performing the DML operation and kick back if not set. You cannot rerender if required fields are not set.
    – BradByte
    Commented Dec 17, 2014 at 21:43

1 Answer 1

5

Try wrapping the code you want to isolate inside an <apex:actionRegion/> tag. This will only submit the elements inside that region to the controller and may allow you to bypass the required field. Here's a dev doc: https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionRegion.htm.

1
  • yes this works... and of course action region destroys all my formatting. time to make another question..
    – logeyg
    Commented Dec 17, 2014 at 22:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .