Permalink
Browse files

Remove tagIsInvalid()

With the addition of error templates, I think this method is mostly
useless, and can be replaced with `$this->Form->context()->hasError()`
where it is really required.
  • Loading branch information...
markstory committed Feb 20, 2014
1 parent 8de9a27 commit 92daf3df0376d2696cb53e6bfd0d268928e7364b
Showing with 0 additions and 62 deletions.
  1. +0 −20 src/View/Helper/FormHelper.php
  2. +0 −42 tests/TestCase/View/Helper/FormHelperTest.php
@@ -268,26 +268,6 @@ protected function _isRequiredField($validationRules) {
return false;
}
-/**
- * Returns false if given form field described by the current entity has no errors.
- * Otherwise it returns the validation message
- *
- * @return mixed Either false when there are no errors, or an array of error
- * strings. An error string could be ''.
- * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::tagIsInvalid
- */
- public function tagIsInvalid() {
- $entity = $this->entity();
- $model = array_shift($entity);
-
- // 0.Model.field. Fudge entity path
- if (empty($model) || is_numeric($model)) {
- array_splice($entity, 1, 0, $model);
- $model = array_shift($entity);
- }
- return false;
- }
-
/**
* Returns an HTML FORM element.
*
@@ -2020,48 +2020,6 @@ public function testUnlockFieldRemovingFromFields() {
$this->assertEquals(array(), $this->Form->fields);
}
-/**
- * testTagIsInvalid method
- *
- * @return void
- */
- public function testTagIsInvalid() {
- $this->markTestIncomplete('Need to revisit once models work again.');
- $Contact->validationErrors[0]['email'] = $expected = array('Please provide an email');
-
- $this->Form->setEntity('Contact.0.email');
- $result = $this->Form->tagIsInvalid();
- $this->assertEquals($expected, $result);
-
- $this->Form->setEntity('Contact.1.email');
- $result = $this->Form->tagIsInvalid();
- $this->assertFalse($result);
-
- $this->Form->setEntity('Contact.0.name');
- $result = $this->Form->tagIsInvalid();
- $this->assertFalse($result);
- }
-
-/**
- * Test tagIsInvalid with validation errors from a saveMany
- *
- * @return void
- */
- public function testTagIsInvalidSaveMany() {
- $this->markTestIncomplete('Need to revisit once models work again.');
- $Contact->validationErrors[0]['email'] = $expected = array('Please provide an email');
-
- $this->Form->create('Contact');
-
- $this->Form->setEntity('0.email');
- $result = $this->Form->tagIsInvalid();
- $this->assertEquals($expected, $result);
-
- $this->Form->setEntity('0.Contact.email');
- $result = $this->Form->tagIsInvalid();
- $this->assertEquals($expected, $result);
- }
-
/**
* Test validation errors.
*

0 comments on commit 92daf3d

Please sign in to comment.