Use HTML in error message |
Hi,
i define my error messages in a language file: PHP Code: return [ Is it possible to use HTML in this message PHP Code: return [ Now the html tag will be displayed as text
In my local CI 4.4.6 enviroment the following text is displayed with italic:
'bankDetails' => 'These are the <i>Bank details</i>', Otherwise, try: echo html_entity_decode(lang('Dashboard.bankDetails'));
Hi,
in my template i use echo $validation->showError('field'). Where should i place the htm_entity_decode?
Try this, you might be lucky, haven't tested it myself:
PHP Code: html_entity_decode($validation->showError('field'));
I wonder why it is working on your installation and not in my installation. Are the validation language files handled different than other language files?
btw: your solution is working
I didn't test it with a validation language file, but in a regular language file.
I am not sure if you have seen this: https://codeigniter4.github.io/userguide...ion-labels If your problem is solved by using the proposed solution, please mark the thread as solved.
Hi, could you test it with a validation file? Your solution is working, but i have to adjust all my templates. If it is working with a regular language file why not with with validation?
Warning
If you get the error messages with getErrors() or getError(), the messages are not HTML escaped. If you use user input data like ({value}) to make the error message, it might contain HTML tags. If you don’t escape the messages before displaying them, XSS attacks are possible. https://codeigniter4.github.io/CodeIgnit...r-messages
Ok, i understand. I thought there is only the {field} placeholder which is no user input
|
Welcome Guest, Not a member yet? Register Sign In |