我使用的 inputField 直接绑定(bind)到 Controller 中的自定义对象字段。 下面将生成一个带有标签的下拉列表。
<apex:inputField value="{!Agency_Profile.Location_Principal_Activity__c}" />
我的问题是我需要在 inputField 旁边添加所需的标记,而不会丢失标签或具有默认错误消息。
当我使用时
<apex:inputField value="{!Agency_Profile.Location_Principal_Activity__c}" required="true"/>
我获得了所需的标记,但丢失了用于验证的自定义错误消息。
当我使用时
<apex:outputPanel styleClass="requiredInput" layout="block">
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:inputField value="{!Agency_Profile.Location_Principal_Activity__c}" />
</apex:outputPanel>
下拉列表附近的标签不再显示..
有什么方法可以实现我所需要的吗?
最佳答案
我最终使用了这个。
//this part to add the missing label.
<apex:outputLabel styleclass="labelCol" value="{!$ObjectType.Agency_Profile__c.fields.Location_Principal_Activity__c.Label}" />
<apex:outputPanel styleClass="requiredInput" layout="block">
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:inputField value="{!Agency_Profile.Location_Principal_Activity__c}" />
</apex:outputPanel>
关于salesforce - 带有自定义错误消息的输入字段必填标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13309597/