function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jgrenfelljgrenfell 

Rerender a form and required fields

I have page with a custom controller and a tab panel.  In one of the tabs, I want the user to be able to flip between a view to enter a new record and a list of historical records.  I'm using a boolean variable to track which form (new or historical) should be rendered and a commandlink to set that variable.  Every time I click on that commandLink though, the new form remains with the "You must enter a value" error on the required fields in the form.  I don't want that form saved though and can't seem to get around.  I've tried filling in those fields and then hitting the commandlink, but the same thing happens.  What am I missing?

 

Code for that tab:

 

<apex:tab id="tabFLSEReferral" label="FLSE Referral" rendered="{!IF(student==null, false, true)}"> <apex:form id="formFLSEReferral" rendered="{!modeNewFLSERef}"> <apex:commandLink action="{!linkFLSENewRef}" rerender="formFLSEReferral, formFLSEReferralHistory" value="{!IF(modeNewFLSERef, 'View Referral History', 'Enter New Referral')}" style="font-weight:bold;font-color:#0000ff;font-size:12" /> <apex:pageBlock id="pageFLSEReferral" rendered="{!modeNewFLSERef}"> <apex:pageblockButtons ><apex:commandButton action="{!save_flseReferral}" value="Save"/></apex:pageblockButtons> <!-- NEW / EDIT --> <apex:pageBlockSection columns="2"> <apex:pageBlockSectionItem > Referral?: <apex:inputField value="{!flseRef.Referralcheckbox__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > Referred By: <apex:inputField value="{!flseRef.Referred_By__c}" required="true" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > Referral Date: <apex:inputField value="{!flseRef.Referral_Date__c}" required="true" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <!-- HISTORICAL RECORDS --> <apex:form id="formFLSEReferralHistory" rendered="{!Not(modeNewFLSERef)}"> <apex:pageBlock id="pageFLSEReferralHistory" rendered="{!Not(modeNewFLSERef)}"> <apex:pageblockSection columns="1"> <apex:pageBlockSectionItem > <apex:pageBlockTable value="{!flseReferrals}" var="flseRef"> <apex:column headervalue="Action" > <apex:commandLink action="{!linkflseEditRef}" rerender="formFLSEReferral, formFLSEReferralHistory" value="edit"> <apex:param name="selectedId" value="{!flseRef.id}"/> </apex:commandLink> </apex:column> <apex:column headervalue="Profile" value="{!flseRef.Profile_Status_FLSE_notes__c}"/> <apex:column headervalue="Component" value="{!flseRef.Profile_FLSE_Component__c}"/> <apex:column headervalue="Created Date" value="{!flseRef.CreatedDate}"/> </apex:pageBlockTable> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:tab>

 Code for that commandLink (I added the clear method to try to avoid this, but to no avail):

 

public PageReference linkFLSENewRef() { this.modeNewFLSERef = (modeNewFLSERef ? false : true); if (!this.modeNewFLSERef){ this.flseRef.clear(); } return null; }

 

 

 

 

 

Ron HessRon Hess

Try adding immediate="true" on your command link

 

this will run your code without validating the form input fields.

jgrenfelljgrenfell
That did it, thanks!  Strangely enough, in experimenting with this, switching the commandLink to a commandButton also fixed it, without using immediate="true".  Maybe immediate="true" is the default for the button but not the link?