function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tonitonitonetonitonitone 

how to give input field an error highlight from custom controller?

I wrote some validation inside a custom controller that goes beyond the required field validation. The error message appears fine at the top of the page using new ApexPages.Message(ApexPages.severity.ERROR,'...'). But how do I give an input field an error highlighting from the custom controller?
tonitonitonetonitonitone
So I find that I can do this --

getCustomObject().custom_field__c.addError('some error');

but the target field is still not getting highlighted or flagged in any way, so I'm not sure how to 'retrieve' the error or what happened to the error that I have added to the field.


Just to be clear, I am trying to accomplish something that looks like this --

tonitonitonetonitonitone
if anyone's interested, I achieved this using a workaround, by setting the styleClass attribute --

styleClass="{!IF(some_condition,'errorMsg','')}"