Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update button() to use new widget classes.

  • Loading branch information...
commit 555a376acb5b913390061d3894306ccc4bbae4dd 1 parent d83c305
@markstory markstory authored
View
13 src/View/Helper/FormHelper.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);
}
/**
View
7 tests/TestCase/View/Helper/FormHelperTest.php
@@ -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');
Please sign in to comment.
Something went wrong with that request. Please try again.