2

I am trying to create a simple html output that looks like this

<button class="searchbutton" id="search_button" type="submit">-->
      <i class="icon-search"></i> Search</button>

with Cake php's form helper, i cant figure out why the 'after' attribute doesn't add the inner <i> </i> html element.

This is what i have tried.

  echo $this->Form->button('Search', array('type' => 'submit','id' => 'search_button','class' => 'searchbutton',
        'after' => "<i class='icon-search'></i>"));

3 Answers 3

2

You just include the extra <i></i> tag in the button $title, also include 'escape' => false to ensure the mark up is not escaped, even though is not escaped by default as on v3.1.1, this may change in future, who knows..

Example:

echo $this->Form->button("<i class='icon-search'></i> Search", array('type' => 'submit','id' => 'search_button', 'class' => 'searchbutton', 'escape' => false));
Sign up to request clarification or add additional context in comments.

Comments

0

Please try below code.

echo $this->Form->button('Search', array('type' => 'submit','id' => 'search_button','class' => 'searchbutton','escape' => true,
        'after' => "<i class='icon-search'></i>"));

1 Comment

it is possible, see my answer below
0

see this

echo $this->Form->button('Search', array('type' => 'submit','id' => 'search_button','class' => 'searchbutton','escape' => true, 'after' => "<i class='icon-search'></i>"));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.