1

Is there a way to do this with FormHelper:

<button type="submit" class="btn"><i class="icon-search"></i> Sign in</button>

I tried it using $this->Form->end(); but it doesn't work as I wanted.

1
  • Will you state specifically what you are trying to accomplish? Commented May 29, 2013 at 18:14

2 Answers 2

5

Did you read the manual? Seems like this is what you're looking for;

Creating buttons and submit elements

Something like this should probably work;

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

3 Comments

Don't forget 'escape' => false in the options array, or the <i> will get escaped and passed through to be visible on the final page. You might also want to check out the Twitter Bootstrap Helper. (Full disclosure: the company I work for is responsible for that project.)
@beporter I originally added the escape option, but according to the documentation, for button(), the default is already 'false' (which is inconsistent with 'input' and the HtmlHelper). I didn't test my example though, documentation may be wrong
@thaJeztah Ah you are correct it's unnecessary, but it's probably a good habit to advocate. Doing it (perhaps unnecessarily) here will encourage proper usage elsewhere.
0

Have you tried this?

?>
<button type="submit" class="btn"><i class="icon-search"></i> Sign in</button>
<?php

Remember - CakePHP is there to help make things easier. If you have an already-simple task, there's no reason to complicate it.

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.