BakingPlate icon indicating copy to clipboard operation
BakingPlate copied to clipboard

Issues with FormHelper

Open novrian opened this issue 12 years ago • 1 comments

Hi

First, this is how I extending the Cake-default HTML, Form, and Paginator

    public $helpers = array(
        'BakingPlate.Plate',
        'Html' => array(
            'className' => 'BakingPlate.HtmlPlus'
        ),
        'Form' => array(
            'className' => 'BakingPlate.FormPlus'
        ),
        'Paginator' => array(
            'className' => 'BakingPlate.PaginatorPlus'
        )
    );

I just try to make a button with Form Helper in my View file, and I wanna disable escaping on button text, here's the code

echo $this->Form->button('<i class="icon-plus"></i>&nbsp;&nbsp;Add', array(
    'type' => 'submit',
    'class' => 'btn btn-large btn-primary',
    'escape' => false
));

When I refreshed the page, I've got this error:

Warning (2): vsprintf(): Too few arguments [CORE\Cake\View\Helper\HtmlHelper.php, line 912]

Stack Trace

vsprintf - [internal], line ??
HtmlHelper::useTag() - CORE\Cake\View\Helper\HtmlHelper.php, line 912
FormHelper::button() - CORE\Cake\View\Helper\FormHelper.php, line 1559
include - APP\View\User\add.ctp, line 69
View::_evaluate() - CORE\Cake\View\View.php, line 923
View::_render() - CORE\Cake\View\View.php, line 886
View::render() - CORE\Cake\View\View.php, line 476
Controller::render() - CORE\Cake\Controller\Controller.php, line 956
Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 193
Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 161
[main] - APP\webroot\index.php, line 92

Well, the bug is in the button's index on $_tags property in HtmlPlusHelper

...
'button' => '<button type="%s"%s>%s</button>',
...

When I change the button's array in$_tags` property to this, it works fine

'button' => '<button%s>%s</button>'

I use Cake 2.2.4

Regards, Novrian :)

novrian avatar Dec 04 '12 20:12 novrian

Do you mind checking to see if any other tags in this array were changed and perhaps open a Pull Request containing the fixes?

ProLoser avatar Dec 04 '12 21:12 ProLoser