You need to sign in to do that
Don't have an account?
Ab
Customizing required and rendered components for inputField
Hello,
I have a custom object like below:
I want to control the display of the CustomField2__c depending on CustomField1__c
if(CustomField1__c = 'val1')
then CustomField2__c should be mandatory
else if (CustomField1__c = 'val2')
then CustomField2__c is hidden and should be not mandatory
else if (CustomField1__c = 'val3')
then the CustomField2__c is visible but not mandatory
I have a custom object like below:
CustomObj__c CustomField1__c (Picklist, values = Val1, Val2, val3) CustomField2__c (lookup)
I want to control the display of the CustomField2__c depending on CustomField1__c
if(CustomField1__c = 'val1')
then CustomField2__c should be mandatory
else if (CustomField1__c = 'val2')
then CustomField2__c is hidden and should be not mandatory
else if (CustomField1__c = 'val3')
then the CustomField2__c is visible but not mandatory
<apex:inputField value="{!CustomObj__c.CustomField2__c }" required="{!logic1}" rendered="{logic2}"/>thank you for suggestions !
One way to realize dynamic/conditional required field is AJAX refreshes.
The following is an example of partial page refreshing.
See VF developer guide
- actionsupport tag : https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionSupport.htm
- Using Ajax in a Page : https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_ajax_partial_page_update_any_component.htm