salesforce - 带有自定义错误消息的输入字段必填标记

标签 salesforce visualforce input-field

我使用的 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/

相关文章:

javascript - 如何从输入字段中获取数字值?

testing - Salesforce/Apex,为什么 TestDataFactory 类包含在代码覆盖率中?

salesforce - 如何在 SalesForce 中获得新线索的通知?

salesforce - 在 salesforce 中搜索全局变量 $Label 的实例

html - 渲染为 pdf 时出现 Visualforce 样式问题

salesforce - 无法在开发者控制台中使用 "Query Editor"

reactjs - 当initialValues通过\绑定(bind)到props.object时,如何使用Formik表单将焦点设置在TextField\input上?

salesforce - 带子查询的SOQL查询

javascript - 如何清除 Visualforce 页面中的查找字段值?

html - 将输入类型设置为数字使输入宽度变短