PHP Class Prado\Web\UI\WebControls\TConditional
TConditional displays appropriate content based on the evaluation result
of a PHP expression specified via {@link setCondition Condition}.
If the result is true, it instantiates the template {@link getTrueTemplate TrueTemplate};
otherwise, the template {@link getFalseTemplate FalseTemplate} is instantiated.
The PHP expression is evaluated right before {@link onInit} stage of the control lifecycle.
Since {@link setCondition Condition} is evaluated at a very early stage, it is recommended
you set {@link setCondition Condition} in template and the expression should not refer to
objects that are available on or after {@link onInit} lifecycle.
A typical usage of TConditional is shown as following:
Login
Logout
TConditional is very light. It instantiates either {@link getTrueTemplate TrueTemplate}
or {@link getFalseTemplate FalseTemplate}, but never both. And the condition is evaluated only once.
ファイルを表示
Open project: pradosoft/prado
Public Methods
Method Details
addParsedObject()
public method
This method overrides the parent implementation by removing
all contents enclosed in the template tag.
createChildControls()
public method
This method overrides the parent implementation. It evaluates {@link getCondition Condition}
and instantiate the corresponding template.
getCondition()
public method
public getCondition ( ) : string |
return |
string |
the PHP expression used for determining which template to use. Defaults to 'true', meaning using TrueTemplate. |
getFalseTemplate()
public method
public getFalseTemplate ( ) : Prado\Web\UI\ITemplate |
return |
Prado\Web\UI\ITemplate |
the template applied when {@link getCondition Condition} is false. |
getTrueTemplate()
public method
public getTrueTemplate ( ) : Prado\Web\UI\ITemplate |
return |
Prado\Web\UI\ITemplate |
the template applied when {@link getCondition Condition} is true. |
setCondition()
public method
The context of the expression is the template control containing TConditional.
setFalseTemplate()
public method
public setFalseTemplate ( Prado\Web\UI\ITemplate $value ) |
$value |
Prado\Web\UI\ITemplate |
|
setTrueTemplate()
public method
public setTrueTemplate ( Prado\Web\UI\ITemplate $value ) |
$value |
Prado\Web\UI\ITemplate |
|