2

I have used custom label in messageWhenValueMissing attribute but it doesn't get displayed in UI.

Is there a way to use custom label in messageWhenValueMissing. This is necessary since multiple countries will be using the component and they need it in their own language.

<lightning:select label="Reason" value="{!v.reasonValue}" required="true" 
 messageWhenValueMissing="{!$label.c.please_provide_reason}">
  • did you try by setCustomValidity? – sdandamud1 May 14 '19 at 14:41
2

It seems the keyword Label is case sensitive in this context. With a quick test I was able to reflect the message from a custom label using Label (starting with UPPERCASE L).

Change the keyword from label to Label and that should work, as below:

<lightning:select label="Reason" value="{!v.reasonValue}" required="true" 
                  messageWhenValueMissing="{!$Label.c.please_provide_reason}">
  • Yes this works, looks like Label is case sensitive only in such scenarios cuz this works correctly <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">{!$label.c.Select_reason_for_reopenin}</h2> – devforce May 14 '19 at 14:59
  • Yeah, that's a bit odd. I would have expected this to have the same behavior everywhere but doesn't seem to be the case. – Jayant Das May 14 '19 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.