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

Thursday, April 21, 2022

[FIXED] Why we use escape => false in cakephp

 April 21, 2022     cakephp-2.3, php     No comments   

Issue

echo $this->Html->link(
    '<span class="glyphicon glyphicon-remove"></span> Cancel',    
    array(
        'action'=>'index', 
        'page:'.$this->request->data['Transaction']['page']
    ),
    array(
        'class'=>'btn btn-default', 
        'escape'=>false
    ), 
    'Do you want to cancel ?'
);

Solution

Because your label is HTML rather than plain text.

You don't want to insert a literal <span class="glyphicon glyphicon-remove"></span> text, you want an HTML tag to display an icon.

    // lib/Cake/View/Helper/HtmlHelper.php
    if (isset($options['escapeTitle'])) {
        $escapeTitle = $options['escapeTitle'];
        unset($options['escapeTitle']);
    } elseif (isset($options['escape'])) {
        $escapeTitle = $options['escape'];
    }

    if ($escapeTitle === true) {
        $title = h($title);
    } elseif (is_string($escapeTitle)) {
        $title = htmlentities($title, ENT_QUOTES, $escapeTitle);
    }


Answered By - Álvaro González
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

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