We have this simple structure
<apex:pageBlock>
<apex:pageblocksection title="Personal Details">
<apex:inputfield value="{!acc.Name}" />
<apex:inputfield value="{!acc.Custom1__c}" id="re1" />
<apex:inputfield value="{!acc.Custom2__c}" id="re2" required="true" />
</apex:pageblocksection>
</apex:pageBlock>
Now I want to hide the (required) re2 inputfield if re1 is equal to 'test', but do not want to rerender the other fields.
However, if I wrap the apex:inputField in an outputpanel with an id like the following example, and then rerender that thing, then the inputfield becomes really ugly. How to do this?
<apex:pageBlock>
<apex:pageblocksection title="Personal Details">
<apex:inputfield value="{!acc.Name}" />
<apex:inputfield value="{!acc.Custom1__c}" id="re1" onchange="checkRe2Visibility();" />
<apex:outputPanel id="wrapper">
<apex:inputfield value="{!acc.Custom2__c}" id="re2" rendered="{!acc.Custom1__c != 'test'}" required="true" />
</apex:outputPanel>
</apex:pageblocksection>
</apex:pageBlock>
<apex:actionFunction reRender="wrapper" name="checkRe2Visibility"/>
Thanks!
outputPanel
? after which action you are rerendering it? can you post the related controller code as well?re2
? Some commandButton, onchange event forre1
, something else?re2
with the red bar (many google links on how to do this), and 3) have the controller testre2's
required state when a 'save' action method executes. I had the same issues as you with stylingre1
if it were wrapped inside of anactionRegion
(so as to only xmitre1
). If you don't need to use pageBlock styling, problem gets easier.