CFormElement
CFormElement is the base class for presenting all kinds of form element.
CFormElement implements the way to get and set arbitrary attributes.
Public Properties
Property |
Type |
Description |
Defined By |
attributes | array | list of attributes (name=>value) for the HTML element represented by this object. | CFormElement |
parent | mixed | the direct parent of this element. | CFormElement |
visible | boolean | Returns a value indicating whether this element is visible and should be rendered. | CFormElement |
Protected Methods
Method |
Description |
Defined By |
evaluateVisible() | Evaluates the visibility of this element. | CFormElement |
Property Details
public array $attributes;
list of attributes (name=>value) for the HTML element represented by this object.
public mixed getParent()
the direct parent of this element. This could be either a CForm object or a CBaseController object (a controller or a widget).
public boolean getVisible()
public void setVisible(boolean $value)
Returns a value indicating whether this element is visible and should be rendered. This method will call evaluateVisible to determine the visibility of this element.
Method Details
public void __construct(mixed $config, mixed $parent) |
$config | mixed | the configuration for this element. |
$parent | mixed | the direct parent of this element. |
Constructor.
public mixed __get(string $name) |
$name | string | the property or attribute name |
{return} | mixed | the property or attribute value |
Source Code: framework/web/form/CFormElement.php#77 (
show)
public function __get($name)
{
$getter='get'.$name;
if(method_exists($this,$getter))
return $this->$getter();
elseif(isset($this->attributes[$name]))
return $this->attributes[$name];
else
throw new CException(Yii::t('yii','Property "{class}.{property}" is not defined.',
array('{class}'=>get_class($this), '{property}'=>$name)));
}
Returns a property value or an attribute value. Do not call this method. This is a PHP magic method that we override to allow using the following syntax to read a property or attribute:
$value=$element->propertyName;
$value=$element->attributeName;
public boolean __isset(string $name) |
$name | string | the property or attribute name |
{return} | boolean | |
Source Code: framework/web/form/CFormElement.php#99 (
show)
public function __isset($name)
{
$getter='get'.$name;
if(method_exists($this,$getter))
return $this->$getter()!==null;
elseif(isset($this->attributes[$name]))
return isset($this->attributes[$name]);
else
return false;
}
Checks a property value or an attribute value on existence or not null Do not call this method. This is a PHP magic method that we override to allow using the following syntax to read a property or attribute:
isset($element->propertyName);
public void __set(string $name, mixed $value) |
$name | string | the property or attribute name |
$value | mixed | the property or attribute value |
Sets value of a property or attribute. Do not call this method. This is a PHP magic method that we override to allow using the following syntax to set a property or attribute.
$this->propertyName=$value;
$this->attributeName=$value;
public string __toString() |
{return} | string | the string representation of this object. |
Converts the object to a string. This is a PHP magic method. The default implementation simply calls render and return the rendering result.
public void configure(mixed $config) |
$config | mixed | the configuration for this object. This can be an array representing the property names and their initial values. It can also be a string representing the file name of the PHP script that returns a configuration array. |
Source Code: framework/web/form/CFormElement.php#138 (
show)
public function configure($config)
{
if(is_string($config))
$config=require(Yii::getPathOfAlias($config).'.php');
if(is_array($config))
{
foreach($config as $name=>$value)
$this->$name=$value;
}
}
Configures this object with property initial values.
protected boolean evaluateVisible() |
{return} | boolean | whether this element is visible. Defaults to true. |
Evaluates the visibility of this element. Child classes should override this method to implement the actual algorithm for determining the visibility.
public mixed getParent() |
{return} | mixed | the direct parent of this element. This could be either a CForm object or a CBaseController object (a controller or a widget). |
public boolean getVisible() |
{return} | boolean | whether this element is visible and should be rendered. |
Returns a value indicating whether this element is visible and should be rendered. This method will call evaluateVisible to determine the visibility of this element.
abstract public string render() |
{return} | string | the rendering result |
Renders this element.
public void setVisible(boolean $value) |
$value | boolean | whether this element is visible and should be rendered. |