Salesforce inputField required标记,带有自定义错误msgs
我使用的inputField直接绑定到控制器中的自定义对象字段。 下面将生成一个带有标签的下拉列表Salesforce inputField required标记,带有自定义错误msgs,salesforce,visualforce,input-field,Salesforce,Visualforce,Input Field,我使用的inputField直接绑定到控制器中的自定义对象字段。 下面将生成一个带有标签的下拉列表 <apex:inputField value="{!Agency_Profile.Location_Principal_Activity__c}" /> 我的问题是,我需要在inputField旁边添加所需的标记,而不会丢失标签或出现默认错误msgs 当我使用 <apex:inputField value="{!Agency_Profile.Location_Princi
<apex:inputField value="{!Agency_Profile.Location_Principal_Activity__c}" />
我的问题是,我需要在inputField旁边添加所需的标记,而不会丢失标签或出现默认错误msgs
当我使用
<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>
我获得了要求的分数,但我丢失了用于验证的自定义错误msgs
当我使用
<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>
//此部分用于添加缺少的标签。
我最终使用了这个
//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>
//此部分用于添加缺少的标签。
最好的方法是为该对象的此字段添加。最好的方法是为该对象的此字段添加。使用raym0nds方法,这就是它如何查找自定义控制器变量的方法,在我的例子中,该变量的名称来自对象的自定义字段。
//this part to add the missing label.
<apex:outputLabel for="myId" 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:inputText id="myId" required="true" value="{!myCustomField}" label="{!$ObjectType.Agency_Profile__c.fields.Location_Principal_Activity__c.Label}" />
</apex:outputPanel>
//此部分用于添加缺少的标签。
请注意apex:inputText
类型,它现在有一个标签
、id
和必需的
属性。apex:outputLabel
现在有一个for
属性。/id的
就是这样,单击标签将光标放在右侧字段中。required
启用表单验证,因为其余的只是补足。标签
为该验证错误添加了一个好的字段名-否则它将在那里显示内部字段id
如果您有一个批量编辑表,其中所有记录共享某些值(例如,为同一家公司添加多个Lead),那么整个方法很有趣。使用raym0nds方法,它就是这样查找自定义控制器变量的。,在我的例子中,该变量的名称来自对象的自定义字段。:
//this part to add the missing label.
<apex:outputLabel for="myId" 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:inputText id="myId" required="true" value="{!myCustomField}" label="{!$ObjectType.Agency_Profile__c.fields.Location_Principal_Activity__c.Label}" />
</apex:outputPanel>
//此部分用于添加缺少的标签。
请注意apex:inputText
类型,它现在有一个标签
、id
和必需的
属性。apex:outputLabel
现在有一个for
属性。/id的
就是这样,单击标签将光标放在右侧字段中。required
启用表单验证,因为其余的只是补足。标签
为该验证错误添加了一个好的字段名-否则它将在那里显示内部字段id
如果您有一个批量编辑表,其中所有记录共享某些值(例如,为同一家公司添加多个Lead)添加不会在visualforce页面中的字段附近显示红色标记的记录,则整个方法很有趣。我将检查。但甚至应该有一个字段用于输入错误消息。添加该字段不会在visualforce页面的字段附近显示红色标记。我会检查。但甚至应该有一个字段用于输入错误消息。