public function buildExpression()
    {
        /** @var EditableFormField $formFieldWatch */
        $formFieldWatch = $this->ConditionField();
        //Encapsulated the action to the object
        $action = $formFieldWatch->getJsEventHandler();

        // is this field a special option field
        $checkboxField = $formFieldWatch->isCheckBoxField();
        $radioField = $formFieldWatch->isRadioField();
        $target = sprintf('$("%s")', $formFieldWatch->getSelectorFieldOnly());
        $fieldValue = Convert::raw2js($this->FieldValue);

        $conditionOptions = [
            'ValueLessThan'         => '<',
            'ValueLessThanEqual'    => '<=',
            'ValueGreaterThan'      => '>',
            'ValueGreaterThanEqual' => '>='
        ];

        // and what should we evaluate
        switch ($this->ConditionOption) {
            case 'IsNotBlank':
            case 'IsBlank':
                $expression = ($checkboxField || $radioField) ? "!{$target}.is(\":checked\")" : "{$target}.val() == ''";
                if ((string) $this->ConditionOption === 'IsNotBlank') {
                    //Negate
                    $expression = "!({$expression})";
                }
                break;
            case 'HasValue':
            case 'ValueNot':
                if ($checkboxField) {
                    if ($formFieldWatch->isCheckBoxGroupField()) {
                        $expression = sprintf(
                            "$.inArray('%s', %s.filter(':checked').map(function(){ return $(this).val();}).get()) > -1",
                            $fieldValue,
                            $target
                        );
                    } else {
                        $expression = "{$target}.prop('checked')";
                    }
                } elseif ($radioField) {
                    // We cannot simply get the value of the radio group, we need to find the checked option first.
                    $expression = sprintf(
                        '%s.closest(".field, .control-group").find("input:checked").val() == "%s"',
                        $target,
                        $fieldValue
                    );
                } else {
                    $expression = sprintf('%s.val() == "%s"', $target, $fieldValue);
                }

                if ((string) $this->ConditionOption === 'ValueNot') {
                    //Negate
                    $expression = "!({$expression})";
                }
                break;
            case 'ValueLessThan':
            case 'ValueLessThanEqual':
            case 'ValueGreaterThan':
            case 'ValueGreaterThanEqual':
                $expression = sprintf(
                    '%s.val() %s parseFloat("%s")',
                    $target,
                    $conditionOptions[$this->ConditionOption],
                    $fieldValue
                );
                break;
            default:
                throw new LogicException("Unhandled rule {$this->ConditionOption}");
                break;
        }

        $result = [
            'operation' => $expression,
            'event'     => $action,
        ];

        return $result;
    }
public function buildExpression()
    {
        /** @var EditableFormField $formFieldWatch */
        $formFieldWatch = $this->ConditionField();
        //Encapsulated the action to the object
        $action = $formFieldWatch->getJsEventHandler();

        // is this field a special option field
        $checkboxField = $formFieldWatch->isCheckBoxField();
        $radioField = $formFieldWatch->isRadioField();
        $target = sprintf('$("%s")', $formFieldWatch->getSelectorFieldOnly());
        $fieldValue = Convert::raw2js($this->FieldValue);

        $conditionOptions = [
            'ValueLessThan'         => '<',
            'ValueLessThanEqual'    => '<=',
            'ValueGreaterThan'      => '>',
            'ValueGreaterThanEqual' => '>='
        ];

        // and what should we evaluate
        switch ($this->ConditionOption) {
            case 'IsNotBlank':
            case 'IsBlank':
                $expression = ($checkboxField || $radioField) ? "!{$target}.is(\":checked\")" : "{$target}.val() == ''";
                if ((string) $this->ConditionOption === 'IsNotBlank') {
                    //Negate
                    $expression = "!({$expression})";
                }
                break;
            case 'HasValue':
            case 'ValueNot':
                if ($checkboxField) {
                    if ($formFieldWatch->isCheckBoxGroupField()) {
                        $expression = sprintf(
                            "$.inArray('%s', %s.filter(':checked').map(function(){ return $(this).val();}).get()) > -1",
                            $fieldValue,
                            $target
                        );
                    } else {
                        $expression = "{$target}.prop('checked')";
                    }
                } elseif ($radioField) {
                    // We cannot simply get the value of the radio group, we need to find the checked option first.
                    $expression = sprintf(
                        '%s.closest(".field, .control-group").find("input:checked").val() == "%s"',
                        $target,
                        $fieldValue
                    );
                } else {
                    $expression = sprintf('%s.val() == "%s"', $target, $fieldValue);
                }

                if ((string) $this->ConditionOption === 'ValueNot') {
                    //Negate
                    $expression = "!({$expression})";
                }
                break;
            case 'ValueLessThan':
            case 'ValueLessThanEqual':
            case 'ValueGreaterThan':
            case 'ValueGreaterThanEqual':
                $expression = sprintf(
                    '%s.val() %s parseFloat("%s")',
                    $target,
                    $conditionOptions[$this->ConditionOption],
                    $fieldValue
                );
                break;
            default:
                throw new LogicException("Unhandled rule {$this->ConditionOption}");
                break;
        }

        $result = [
            'operation' => $expression,
            'event'     => $action,
        ];

        return $result;
    }
public function buildExpression ( ) { /** @var EditableFormField $formFieldWatch */ $ formFieldWatch = $ this -> ConditionField ( ) ; //Encapsulated the action to the object $ action = $ formFieldWatch -> getJsEventHandler ( ) ; // is this field a special option field $ checkboxField = $ formFieldWatch -> isCheckBoxField ( ) ; $ radioField = $ formFieldWatch -> isRadioField ( ) ; $ target = sprintf ( '$("%s")' , $ formFieldWatch -> getSelectorFieldOnly ( ) ) ; $ fieldValue = Convert :: raw2js ( $ this -> FieldValue ) ; $ conditionOptions = [ 'ValueLessThan' => '<' , 'ValueLessThanEqual' => '<=' , 'ValueGreaterThan' => '>' , 'ValueGreaterThanEqual' => '>=' ] ; // and what should we evaluate switch ( $ this -> ConditionOption ) { case 'IsNotBlank' : case 'IsBlank' : $ expression = ( $ checkboxField || $ radioField ) ? "!{$target}.is(\":checked\")" : "{$target}.val() == ''" ; if ( ( string ) $ this -> ConditionOption === 'IsNotBlank' ) { //Negate $ expression = "!({$expression})" ; } break ; case 'HasValue' : case 'ValueNot' : if ( $ checkboxField ) { if ( $ formFieldWatch -> isCheckBoxGroupField ( ) ) { $ expression = sprintf ( "$.inArray('%s', %s.filter(':checked').map(function(){ return $(this).val();}).get()) > -1" , $ fieldValue , $ target ) ; } else { $ expression = "{$target}.prop('checked')" ; } } elseif ( $ radioField ) { // We cannot simply get the value of the radio group, we need to find the checked option first. $ expression = sprintf ( '%s.closest(".field, .control-group").find("input:checked").val() == "%s"' , $ target , $ fieldValue ) ; } else { $ expression = sprintf ( '%s.val() == "%s"' , $ target , $ fieldValue ) ; } if ( ( string ) $ this -> ConditionOption === 'ValueNot' ) { //Negate $ expression = "!({$expression})" ; } break ; case 'ValueLessThan' : case 'ValueLessThanEqual' : case 'ValueGreaterThan' : case 'ValueGreaterThanEqual' : $ expression = sprintf ( '%s.val() %s parseFloat("%s")' , $ target , $ conditionOptions [ $ this -> ConditionOption ] , $ fieldValue ) ; break ; default : throw new LogicException ( "Unhandled rule {$this->ConditionOption}" ) ; break ; } $ result = [ 'operation' => $ expression , 'event' => $ action , ] ; return $ result ; }
Substitutes configured rule logic with it's JS equivalents and returns them as array elements

@return array
@throws LogicException If the provided condition option was not able to be handled
Substitutes configured rule logic with it s JS equivalents and returns them as array elements