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: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}"/>

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.

  • 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. – Brad Bumbalough Dec 17 '14 at 21:43

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.

| improve this answer | |
  • yes this works... and of course action region destroys all my formatting. time to make another question.. – logeyg Dec 17 '14 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.