PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, March 15, 2022

[FIXED] How to add <i> and <span> tag inside a tag in cakephp 3?

 March 15, 2022     cakephp, cakephp-3.0     No comments   

Issue

My html code is given below:

<a  href="/patients/index" class="m-menu__link ">
    <i class="m-menu__link-bullet m-menu__link-bullet--dot">
        <span></span>
    </i>
    <span class="m-menu__link-text">
        Add Medicines
    </span>
</a>

and i want to convert it by using HtmlHelper in cakephp 3.


Solution

You want to use the 'escape' => false parameter in the link() method. This stops Cake from escaping the markup:-

<?= $this->Html->link(
    '<i class="m-menu__link-bullet m-menu__link-bullet--dot"><span></span></i><span class="m-menu__link-text">' . h('Add Medicines') . '</span>', 
    '/patients/index', 
    [
        'escape' => false, 
        'class' => 'm-menu__link'
    ]
) ?>

It's important to remember to still escape any user generated content using h(). I've shown this in the example above by escaping 'Add Medicines', but if this is hardcoded you wouldn't need to wrap it in the h() method.



Answered By - drmonkeyninja
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing