mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-06-21 14:13:43 +00:00
Moving tagIsInvalid from Helper back to FormHelper, as it is a better home for it
This commit is contained in:
parent
567ac0209c
commit
22f02373c9
2 changed files with 16 additions and 25 deletions
lib/Cake/View
|
@ -64,14 +64,6 @@ class Helper extends Object {
|
||||||
*/
|
*/
|
||||||
public $plugin = null;
|
public $plugin = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains model validation errors of form post-backs
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $validationErrors = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds tag templates.
|
* Holds tag templates.
|
||||||
*
|
*
|
||||||
|
@ -508,23 +500,6 @@ class Helper extends Object {
|
||||||
return $last;
|
return $last;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
* 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.
|
* Uses the current View::entity() settings to generate a CamelCased id attribute.
|
||||||
|
|
|
@ -180,6 +180,22 @@ class FormHelper extends AppHelper {
|
||||||
return $required;
|
return $required;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Returns an HTML FORM element.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue