Skip to content

Instantly share code, notes, and snippets.

@jimmitchell
Last active July 3, 2016 00:19
Show Gist options
  • Save jimmitchell/4595878 to your computer and use it in GitHub Desktop.
Save jimmitchell/4595878 to your computer and use it in GitHub Desktop.
Force.com Apex code for making a field appear to be required on a Visualforce page.
<!-- update "Object_Name__c" with your Object, and "Field_Name__c" with your Field -->
<apex:pageblocksectionitem helpText="{!$ObjectType.Object_Name__c.Fields.Field_Name__c.inlineHelpText}">
<apex:outputlabel value="{!$ObjectType.Object_Name__c.fields.Field_Name__c.label}" />
<apex:outputpanel layout="block" styleClass="requiredInput">
<apex:outputpanel layout="block" styleClass="requiredBlock"/>
<apex:inputfield value="{!Object_Name__c.Field_Name__c}" />
</apex:outputpanel>
</apex:pageblocksectionitem>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment