Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP: How to use HTML entities in button titles using Form Helper

I'd like to use a checkmark as the text for a button. The entity I want is ✓ but when I put that in as the text for the button using the Form Helper, it always converts the leading ampersand into & so that the text shows but not the entity.

Here's how I'm creating the button:

echo $this->Form->button(
    '✓', 
    array(
        'type' => 'submit', 
        'id' => $checklistItem['ChecklistItem']['id'], 
        'escape' => 'false'
    )
);

and the generated HTML looks like this:

<button type="submit" id="1">&amp;#x2713;</button>

which obviously doesn't render the entity.

I've tried it by setting 'escape' => 'true' but that has not effect at all.

Any ideas?

like image 256
iopener Avatar asked Nov 26 '25 07:11

iopener


1 Answers

You do not need to escape it false, it is by default escaped to false.

  echo $this->Form->button('&#x2713;',  
          array(
               'type' => 'submit', 
               'id' => $checklistItem['ChecklistItem']['id']
           )
  );
like image 199
Vijay Choudhary Avatar answered Nov 28 '25 07:11

Vijay Choudhary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!