public function addCondition($strType, $blnValue, $arrComparisons, $intComparisonType = ValidForm::VFORM_MATCH_ANY)
    {
        if ($this->hasCondition($strType)) {
            // Get an existing condition if it's already there.
            $objCondition = $this->getCondition($strType);
        } else {
            // Add a new one if this condition type doesn't exist yet.
            $objCondition = new Condition($this, $strType, $blnValue, $intComparisonType);
        }

        if (is_array($arrComparisons) && count($arrComparisons) > 0) {
            /* @var $varComparison array|Comparison */
            foreach ($arrComparisons as $varComparison) {
                if (is_array($varComparison) || get_class($varComparison) === "ValidFormBuilder\\Comparison") {
                    try {
                        $objCondition->addComparison($varComparison);
                    } catch (\InvalidArgumentException $e) {
                        throw new \Exception("Could not set condition: " . $e->getMessage(), 1);
                    }
                } else {
                    throw new \InvalidArgumentException("Invalid or no comparison(s) supplied.", 1);
                }
            }

            array_push($this->__conditions, $objCondition);
        } else {
            throw new \InvalidArgumentException("Invalid or no comparison(s) supplied.", 1);
        }
    }
public function addCondition($strType, $blnValue, $arrComparisons, $intComparisonType = ValidForm::VFORM_MATCH_ANY)
    {
        if ($this->hasCondition($strType)) {
            // Get an existing condition if it's already there.
            $objCondition = $this->getCondition($strType);
        } else {
            // Add a new one if this condition type doesn't exist yet.
            $objCondition = new Condition($this, $strType, $blnValue, $intComparisonType);
        }

        if (is_array($arrComparisons) && count($arrComparisons) > 0) {
            /* @var $varComparison array|Comparison */
            foreach ($arrComparisons as $varComparison) {
                if (is_array($varComparison) || get_class($varComparison) === "ValidFormBuilder\\Comparison") {
                    try {
                        $objCondition->addComparison($varComparison);
                    } catch (\InvalidArgumentException $e) {
                        throw new \Exception("Could not set condition: " . $e->getMessage(), 1);
                    }
                } else {
                    throw new \InvalidArgumentException("Invalid or no comparison(s) supplied.", 1);
                }
            }

            array_push($this->__conditions, $objCondition);
        } else {
            throw new \InvalidArgumentException("Invalid or no comparison(s) supplied.", 1);
        }
    }
public function addCondition ( $ strType , $ blnValue , $ arrComparisons , $ intComparisonType = ValidForm :: VFORM_MATCH_ANY ) { if ( $ this -> hasCondition ( $ strType ) ) { // Get an existing condition if it's already there. $ objCondition = $ this -> getCondition ( $ strType ) ; } else { // Add a new one if this condition type doesn't exist yet. $ objCondition = new Condition ( $ this , $ strType , $ blnValue , $ intComparisonType ) ; } if ( is_array ( $ arrComparisons ) && count ( $ arrComparisons ) > 0 ) { /* @var $varComparison array|Comparison */ foreach ( $ arrComparisons as $ varComparison ) { if ( is_array ( $ varComparison ) || get_class ( $ varComparison ) === "ValidFormBuilder\\Comparison" ) { try { $ objCondition -> addComparison ( $ varComparison ) ; } catch ( \ InvalidArgumentException $ e ) { throw new \ Exception ( "Could not set condition: " . $ e -> getMessage ( ) , 1 ) ; } } else { throw new \ InvalidArgumentException ( "Invalid or no comparison(s) supplied." , 1 ) ; } } array_push ( $ this -> __conditions , $ objCondition ) ; } else { throw new \ InvalidArgumentException ( "Invalid or no comparison(s) supplied." , 1 ) ; } }
Add a new condition to the current field

For examples, check {@link \ValidFormBuilder\Condition}

@param string $strType Define the condition type. This can be either `required`, `visibile` or `enabled`
@param boolean $blnValue Define whether this condition activates if the comparison(s) are true or false.
@param array $arrComparisons An array of Comparison objects
@param string $intComparisonType The comparison type.
Either `ValidForm::VFORM_MATCH_ANY` or `ValidForm::VFORM_MATCH_ALL`. With `VFORM_MATCH_ANY`,
as soon as one of the comparisons validates the condition, the condition is enforced.
With `ValidForm::VFORM_MATCH_ALL`, all of the comparisons must validate before the condition will be enforced.

@throws \Exception if Condition could not be set
@throws \InvalidArgumentException If invalid arguments are supplied
Add a new condition to the current field