Skip to content
Permalink
Browse files

Update button() to use new widget classes.

  • Loading branch information...
markstory committed Feb 17, 2014
1 parent d83c305 commit 555a376acb5b913390061d3894306ccc4bbae4dd
Showing with 12 additions and 8 deletions.
  1. +8 −5 src/View/Helper/FormHelper.php
  2. +4 −3 tests/TestCase/View/Helper/FormHelperTest.php
@@ -169,6 +169,7 @@ class FormHelper extends Helper {
* @var array
*/
protected $_defaultTemplates = [
'button' => '<button{{attrs}}>{{text}}</button>',
'checkbox' => '<input type="checkbox" name="{{name}}" value="{{value}}"{{attrs}}>',
'formstart' => '<form{{attrs}}>',
'formend' => '</form>',
@@ -1546,7 +1547,9 @@ public function file($fieldName, $options = array()) {
}
/**
* Creates a `<button>` tag. The type attribute defaults to `type="submit"`
* Creates a `<button>` tag.
*
* The type attribute defaults to `type="submit"`
* You can change it to a different value by using `$options['type']`.
*
* ### Options:
@@ -1560,14 +1563,14 @@ public function file($fieldName, $options = array()) {
*/
public function button($title, $options = array()) {
$options += array('type' => 'submit', 'escape' => false, 'secure' => false);
if ($options['escape']) {
$title = h($title);
}
if (isset($options['name'])) {
$name = str_replace(array('[', ']'), array('.', ''), $options['name']);
$this->_secure($options['secure'], $name);
}
return $this->Html->useTag('button', $options, $title);
unset($options['secure']);
$options['text'] = $title;
return $this->widget('button', $options);
}
/**
@@ -7178,7 +7178,6 @@ public function testFileUploadOnOtherModel() {
* @return void
*/
public function testButton() {
$this->markTestIncomplete('Need to revisit once models work again.');
$result = $this->Form->button('Hi');
$this->assertTags($result, array('button' => array('type' => 'submit'), 'Hi', '/button'));
@@ -7194,7 +7193,10 @@ public function testButton() {
$result = $this->Form->button('No type', array('type' => false));
$this->assertTags($result, array('button' => array(), 'No type', '/button'));
$result = $this->Form->button('Upload Text', array('onClick' => "$('#postAddForm').ajaxSubmit({target: '#postTextUpload', url: '/posts/text'});return false;'", 'escape' => false));
$result = $this->Form->button('Upload Text', array(
'onClick' => "$('#postAddForm').ajaxSubmit({target: '#postTextUpload', url: '/posts/text'});return false;'",
'escape' => false
));
$this->assertNotRegExp('/\&039/', $result);
}
@@ -7204,7 +7206,6 @@ public function testButton() {
* @return void
*/
public function testButtonUnlockedByDefault() {
$this->markTestIncomplete('Need to revisit once models work again.');
$this->Form->request->params['_csrfToken'] = 'secured';
$this->Form->button('Save', array('name' => 'save'));
$this->Form->button('Clear');

0 comments on commit 555a376

Please sign in to comment.
You can’t perform that action at this time.