Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Submit button

How can I create submit button, and define custom title on it, together with custom class style?

like image 609
user198003 Avatar asked Jul 05 '10 20:07

user198003


2 Answers

You could use either submit() or button() methods of the Form helper instead of the end() method. For example:

echo $this->Form->submit(
    'Send', 
    array('class' => 'custom-class', 'title' => 'Custom Title')
);

Don't forget to close the form. You can do it by calling the end() method without any arguments.

echo $this->Form->end();
like image 99
Mike Avatar answered Sep 29 '22 20:09

Mike


Also remember, you can always do it old school

I prefer to use $this->Form->end( ); without arguments and build my own submit buttons and markup. It's easy

<div class="buttons clearfix">
    <button type="submit" class="positive">
        <span class="icon-wrapper"><img src="path/to/tickmark.png" alt="" title="" /></span>
        Save Item
    </button>
</div>

I would also tell you to experiment with the $this->Form->input('Model.field', 'options' => array( array('type' => 'button'))); - particularly the before, between, after, and class options. You can use the helper to create <input type="button" /> elements with a good amount of flexibility.

like image 21
Abba Bryant Avatar answered Sep 29 '22 20:09

Abba Bryant