From 1600889f4ed85d25b06cb1e1ae283e19e429cddd Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 13 Oct 2013 19:50:14 +0200 Subject: [PATCH] added isAttributeActive to Model consistent api for safe and required --- framework/yii/base/Model.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/framework/yii/base/Model.php b/framework/yii/base/Model.php index 93b5a6b..c8c253a 100644 --- a/framework/yii/base/Model.php +++ b/framework/yii/base/Model.php @@ -422,6 +422,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess * Returns a value indicating whether the attribute is safe for massive assignments. * @param string $attribute attribute name * @return boolean whether the attribute is safe for massive assignments + * @see safeAttributes() */ public function isAttributeSafe($attribute) { @@ -429,6 +430,17 @@ class Model extends Component implements IteratorAggregate, ArrayAccess } /** + * Returns a value indicating whether the attribute is active in the current scenario. + * @param string $attribute attribute name + * @return boolean whether the attribute is active in the current scenario + * @see activeAttributes() + */ + public function isAttributeActive($attribute) + { + return in_array($attribute, $this->activeAttributes(), true); + } + + /** * Returns the text label for the specified attribute. * @param string $attribute the attribute name * @return string the attribute label