You need to sign in to do that
Don't have an account?
problem with action support and required fields
Hey all,
I'm having an issue with apex action support and required fields.
I've got two feilds:
Secondary_phone_number__c, and Secondary_phone_number_type__c.
Secondary_phone_number_type__c isrequired when Secondary_phone_number__c is not null.
So I made a little action region base don this tutorial -
http://wiki.developerforce.com/index.php/Visualforce_DynamicEditPage
- but it only partially works.
If I enter a value in Secondary_phone_number__c, then Secondary_phone_number_type__c is rendered AND required, which is correct. But if I change my mind, and delete the value in Secondary_phone_number__c, it re-renders, but still requires Secondary_phone_number_type__c even though it should not...
Here is my applicable code, can anyone help out?
<apex:actionRegion > <apex:panelGrid columns="3" id="thePanelGrid"> <apex:outputPanel> <apex:inputField value="{!Member__c.Secondary_phone_number__c}" id="theInputField"> <apex:actionSupport event="onchange" rerender="thePanelGrid" status="status"/> </apex:inputField> </apex:outputPanel> <apex:inputField value="{!Member__c.Secondary_phone_number_type__c}" required="{!Member__c.Secondary_phone_number__c != null}" rendered="{!Member__c.Secondary_phone_number__c != null}" id="secPhoneType"> <apex:actionSupport event="onchange" rerender="thePanelGrid"/> </apex:inputField> </apex:panelGrid> <apex:actionStatus startText="applying value..." id="status"/> </apex:actionRegion>
Thanks!
All Answers
I've never seen that syntax inside the curly braces. Try
"{!Member__c.Secondary_phone_number__c }!= null"
- Erica
Yes! That would have worked too. What I did was just move it out of the action region alltogether, and it's working well.
Here is my final code:
<apex:pageBlockSectionItem > <apex:outputLabel value="Secondary phone" /> <apex:panelGrid columns="2" styleClass="panelGridAlignCorrect"> <apex:actionRegion > <apex:outputPanel id="theOutputPanel" > <!-- Moved this margin so it would align properly... stupid panel grids!! --> <apex:panelGrid columns="2" style="margin-right:-7px;margin-top:-3px;"> <apex:inputField value="{!Member__c.Secondary_phone_number__c}"> <apex:actionSupport event="onchange" rerender="theOutputPanel, secPhoneTypeGroup, test" status="status"/> </apex:inputField> <apex:actionStatus startText="applying value..." id="status"/> </apex:panelGrid> </apex:outputPanel> </apex:actionRegion> <apex:panelGroup id="secPhoneTypeGroup"> <apex:inputField value="{!Member__c.Secondary_phone_number_type__c}" required="{!Member__c.Secondary_phone_number__c != ''}" rendered="{!Member__c.Secondary_phone_number__c != ''}"/> </apex:panelGroup> </apex:panelGrid> </apex:pageBlockSectionItem>