ソースを参照

Moving tagIsInvalid from Helper back to FormHelper, as it is a better home for it

Jose Lorenzo Rodriguez 14 年 前
コミット
22f02373c9
2 ファイル変更16 行追加25 行削除
  1. 0 25
      lib/Cake/View/Helper.php
  2. 16 0
      lib/Cake/View/Helper/FormHelper.php

+ 0 - 25
lib/Cake/View/Helper.php

@@ -65,14 +65,6 @@ class Helper extends Object {
 	public $plugin = null;
 
 /**
- * Contains model validation errors of form post-backs
- *
- * @access public
- * @var array
- */
-	public $validationErrors = null;
-
-/**
  * Holds tag templates.
  *
  * @access public
@@ -509,23 +501,6 @@ class Helper extends Object {
 	}
 
 /**
- * Returns false if given FORM field has no errors. Otherwise it returns the constant set in
- * the array Model->validationErrors.
- *
- * @param string $model Model name as a string
- * @param string $field Fieldname as a string
- * @param integer $modelID Unique index identifying this record within the form
- * @return boolean True on errors.
- */
-	public function tagIsInvalid($model = null, $field = null, $modelID = null) {
-		$errors = $this->validationErrors;
-		$entity = $this->entity();
-		if (!empty($entity)) {
-			return Set::extract($errors, join('.', $entity));
-		}
-	}
-
-/**
  * Generates a DOM ID for the selected element, if one is not set.
  * Uses the current View::entity() settings to generate a CamelCased id attribute.
  *

+ 16 - 0
lib/Cake/View/Helper/FormHelper.php

@@ -181,6 +181,22 @@ class FormHelper extends AppHelper {
 	}
 
 /**
+ * Returns false if given FORM field has no errors. Otherwise it returns the validation message
+ *
+ * @param string $model Model name as a string
+ * @param string $field Fieldname as a string
+ * @param integer $modelID Unique index identifying this record within the form
+ * @return boolean True on errors.
+ */
+	public function tagIsInvalid($model = null, $field = null, $modelID = null) {
+		$entity = $this->entity();
+		if (!empty($entity) && $object = $this->_getModel($entity[0])) {
+			array_shift($entity);
+			return Set::extract($object->validationErrors, join('.', $entity));
+		}
+	}
+
+/**
  * Returns an HTML FORM element.
  *
  * ### Options: