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.
Afficher le fichier
Open project: pradosoft/prado
Méthodes publiques
Method Details
addParsedObject()
public méthode
This method overrides the parent implementation by removing
all contents enclosed in the template tag.
createChildControls()
public méthode
This method overrides the parent implementation. It evaluates {@link getCondition Condition}
and instantiate the corresponding template.
getCondition()
public méthode
public getCondition ( ) : string |
Résultat |
string |
the PHP expression used for determining which template to use. Defaults to 'true', meaning using TrueTemplate. |
getFalseTemplate()
public méthode
public getFalseTemplate ( ) : Prado\Web\UI\ITemplate |
Résultat |
Prado\Web\UI\ITemplate |
the template applied when {@link getCondition Condition} is false. |
getTrueTemplate()
public méthode
public getTrueTemplate ( ) : Prado\Web\UI\ITemplate |
Résultat |
Prado\Web\UI\ITemplate |
the template applied when {@link getCondition Condition} is true. |
setCondition()
public méthode
The context of the expression is the template control containing TConditional.
setFalseTemplate()
public méthode
public setFalseTemplate ( Prado\Web\UI\ITemplate $value ) |
$value |
Prado\Web\UI\ITemplate |
|
setTrueTemplate()
public méthode
public setTrueTemplate ( Prado\Web\UI\ITemplate $value ) |
$value |
Prado\Web\UI\ITemplate |
|