mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-18 23:43:19 +08:00
added isAttributeActive to Model
consistent api for safe and required
This commit is contained in:
@@ -422,12 +422,24 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
|
|||||||
* Returns a value indicating whether the attribute is safe for massive assignments.
|
* Returns a value indicating whether the attribute is safe for massive assignments.
|
||||||
* @param string $attribute attribute name
|
* @param string $attribute attribute name
|
||||||
* @return boolean whether the attribute is safe for massive assignments
|
* @return boolean whether the attribute is safe for massive assignments
|
||||||
|
* @see safeAttributes()
|
||||||
*/
|
*/
|
||||||
public function isAttributeSafe($attribute)
|
public function isAttributeSafe($attribute)
|
||||||
{
|
{
|
||||||
return in_array($attribute, $this->safeAttributes(), true);
|
return in_array($attribute, $this->safeAttributes(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Returns the text label for the specified attribute.
|
||||||
* @param string $attribute the attribute name
|
* @param string $attribute the attribute name
|
||||||
|
|||||||
Reference in New Issue
Block a user