You need to sign in to do that
Don't have an account?
How to make Multiple PageBlocks work independently
I am sure this is a very simple issue and can be solved easily.
I have multiple PageBlocks in my VisualForce page...
<apex:form >
<apex:pageBlock title="New" mode="edit" id="newCampaignPageBlock">
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" action="{!add}" immediate="true"/>
<apex:commandButton value="Cancel" action="{!cancel}" />
</apex:pageBlockButtons>
<apex:pageBlockSection>
..............
</apex:pageBlockSection>
</apex:pageBlck>
<apex:pageBlock title="Update" mode="edit" id="updateCampaignPageBlock">
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" action="{!update}" immediate="true"/>
apex:commandButton value="Cancel" action="{!cancel}" />
</apex:pageBlockButtons>
<apex:pageBlockSection>
..............
</apex:pageBlockSection>
</apex:pageBlck>
One does "Add" and other "Update".
User can do an Add or Update.
In the above code, when the user just wants to update an existing record and does not
want to do a new, the page complains that some of the required fields for Add are required.
How would I prevent this?
I put in two different forms, it worked. I am not sure if this the most efficient way of doing it though.
I have not tried using "<apex:actionRegion>"..
This is an ideal case for ActionRegions. Simply surround your pageblocks by actionregion tags and only the input elements inside an individual actionregion will be submitted upon click of a button that is also inside the region.
Page 169 of the VisualForce Developer's Guide has full information on the actionregion component.
Hey
You can run into issues using multiple forms. Examples of actionregion usage can be found here.
Wes