__get()
__get(string $property)
Magic getter method
Parameters
string | $property |
Throws
- \BadMethodCallException
Condition class
A condition object is a set of one or more comparisons. Don't use the Condition object as a standalone, rather use the element's \ValidFormBuilder\Base::addCondition() method.
$objCheck = $objForm->addField("yesno", "Yes or No", ValidForm::VFORM_RADIO_LIST);
$objYes = $objCheck->addField("Yes", "yes");
$objCheck->addField("No", "no");
$objText = $objForm->addField(
"textfield",
"Text here",
ValidForm::VFORM_TEXT,
array("required" => "true"),
array("required" => "This field is required"),
array("fielddisabled" => "disabled")
);
$objText->addCondition("enabled", true, array(
new Comparison($objYes, ValidForm::VFORM_COMPARISON_EQUAL, "yes")
));
$objFirstName = $objForm->addField('firstname', 'First name', ValidForm::VFORM_STRING);
$objLastName = $objForm->addField('lastname', 'Last name', ValidForm::VFORM_STRING);
$objLastName->addCondition(
'visible', // Last name will become
false, // 'not visible' (visible -> false)
array(
// When field $objFirstName 'is equal to' Robin
new \ValidFormBuilder\Comparison($objFirstName, ValidForm::VFORM_COMPARISON_EQUAL, 'Robin')
)
);
$objFirstName = $objForm->addField('firstname', 'First name', ValidForm::VFORM_STRING);
$objLastName = $objForm->addField('lastname', 'Last name', ValidForm::VFORM_STRING);
$objFirstName->addCondition(
'enabled', // First Name will be
false, // 'disabled' (enabled -> false)
array(
// When field $objLastName 'is not empty'
// (note that we cal leave out the third 'value' parameter in this case)
new \ValidFormBuilder\Comparison($objLastName, ValidForm::VFORM_COMPARISON_NOT_EMPTY)
)
);
__construct(\ValidFormBuilder\Base $objField, string $strProperty, boolean $blnValue = null, string $strComparisonType = \ValidFormBuilder\ValidForm::VFORM_MATCH_ANY)
Create new Condition
\ValidFormBuilder\Base | $objField | The target field to apply this condition on |
string | $strProperty | The property to trigger on the subject; |
boolean | $blnValue | The boolean to set the property with. E.g. when |
string | $strComparisonType | The comparison type |
If $objField
is no object or $strProperty
is no predefined property.
getSubject() : \ValidFormBuilder\Base
Get subject value
Subject element
addComparison(\ValidFormBuilder\Comparison|array $varComparison)
Add new comparison to Condition
\ValidFormBuilder\Comparison|array | $varComparison | Comparison array or Comparison object |
if Reflection couldn't initialize new Comparison object
if no valid Comparison data is supplied
jsonSerialize(integer|null $intDynamicPosition = null) : array
toJson method creates an array representation of the current condition object and all of it's comparions.
In the future this class should extend the JsonSerializable interface (http://php.net/manual/en/class.jsonserializable.php). Since this is only supported in PHP >= 5.4, we now use our own implementation.
integer|null | $intDynamicPosition |
An array representation of this object and it's comparisons.