Emagister / zend-form-decorators-bootstrap

Zend_Form decorators for Twitter's Bootstrap UI
http://emagister.github.com/zend-form-decorators-bootstrap
168 stars 79 forks source link

Can't create a submit element with an icon #45

Closed clawfire closed 12 years ago

clawfire commented 12 years ago

Twitter_Bootstrap_Form_Element_Submit didn't support icons but Twitter_Bootstrap_Form_Element_Button did. Also we can't make a Button type submitwithout getting the icon as a valuein the generated code , resulting it passed as an element in the post / get call .

lrobert commented 12 years ago

You need to make a Button element and make it of the type 'submit'

<?php
// Inside the form init
$this->addElement('button', 'mySubmitName', array(
    'label' => 'Save',
    'icon' => 'plus-sign',
    'whiteIcon' => true,
    'type' => 'submit'
));

That will get you a submit button with the icon

theUniC commented 12 years ago

Exactly. As @lrobert points out with his example code, in order to get a button with a small icon inside you need to use a Twitter_Bootstrap_Form_Element_Button.

clawfire commented 12 years ago

I'll test that, it's make the type="submit" ok but place the <i class="icon-plus-sign"></i> into the value attribut, so it's passed with the form ...

lrobert commented 12 years ago

'ok but place the into the value attribut'

Place what into the value attribute?

clawfire commented 12 years ago

<i class="icon-plus-sign"></i>

lrobert commented 12 years ago

You can add that directly into the value by using

// Inside the form init
$this->addElement('button', 'mySubmitName', array(
    'label' => 'Save',
    'icon' => 'plus-sign',
    'whiteIcon' => true,
    'type' => 'submit',
    'value' => 'Whatever you want here'
));

But I must ask, why would you want that posted?

clawfire commented 12 years ago

I don't want it, <i class="icon-plus-sign"></i> is automatically inserted into value="" because it's the label of the button :(

lrobert commented 12 years ago

Funny thing, I just ran into this! It doesn't even create the value properly :/

I'll open a new ticket describing the issue and I'll work on a fix.

clawfire commented 12 years ago

@lrobert thx you