public function formatDisplayRules()
    {
        $holderSelector = $this->getSelectorOnly();
        $result = [
            'targetFieldID' => $holderSelector,
            'conjunction'   => $this->DisplayRulesConjunctionNice(),
            'selectors'     => [],
            'events'        => [],
            'operations'    => [],
            'initialState'  => $this->ShowOnLoadNice(),
            'view'          => [],
            'opposite'      => [],
        ];

        // Check for field dependencies / default
        /** @var EditableCustomRule $rule */
        foreach ($this->EffectiveDisplayRules() as $rule) {
            // Get the field which is effected
            /** @var EditableFormField $formFieldWatch */
            $formFieldWatch = DataObject::get_by_id(EditableFormField::class, $rule->ConditionFieldID);
            // Skip deleted fields
            if (!$formFieldWatch) {
                continue;
            }

            $fieldToWatch = $formFieldWatch->getSelectorFieldOnly();

            $expression = $rule->buildExpression();
            if (!in_array($fieldToWatch, $result['selectors'])) {
                $result['selectors'][] = $fieldToWatch;
            }
            if (!in_array($expression['event'], $result['events'])) {
                $result['events'][] = $expression['event'];
            }
            $result['operations'][] = $expression['operation'];

            // View/Show should read
            $result['view'] = $rule->toggleDisplayText($result['initialState']);
            $result['opposite'] = $rule->toggleDisplayText($result['initialState'], true);
            $result['holder'] = $this->getSelectorHolder();
            $result['holder_event'] = $rule->toggleDisplayEvent($result['initialState']);
            $result['holder_event_opposite'] = $rule->toggleDisplayEvent($result['initialState'], true);
        }

        return (count($result['selectors'])) ? $result : null;
    }
public function formatDisplayRules()
    {
        $holderSelector = $this->getSelectorOnly();
        $result = [
            'targetFieldID' => $holderSelector,
            'conjunction'   => $this->DisplayRulesConjunctionNice(),
            'selectors'     => [],
            'events'        => [],
            'operations'    => [],
            'initialState'  => $this->ShowOnLoadNice(),
            'view'          => [],
            'opposite'      => [],
        ];

        // Check for field dependencies / default
        /** @var EditableCustomRule $rule */
        foreach ($this->EffectiveDisplayRules() as $rule) {
            // Get the field which is effected
            /** @var EditableFormField $formFieldWatch */
            $formFieldWatch = DataObject::get_by_id(EditableFormField::class, $rule->ConditionFieldID);
            // Skip deleted fields
            if (!$formFieldWatch) {
                continue;
            }

            $fieldToWatch = $formFieldWatch->getSelectorFieldOnly();

            $expression = $rule->buildExpression();
            if (!in_array($fieldToWatch, $result['selectors'])) {
                $result['selectors'][] = $fieldToWatch;
            }
            if (!in_array($expression['event'], $result['events'])) {
                $result['events'][] = $expression['event'];
            }
            $result['operations'][] = $expression['operation'];

            // View/Show should read
            $result['view'] = $rule->toggleDisplayText($result['initialState']);
            $result['opposite'] = $rule->toggleDisplayText($result['initialState'], true);
            $result['holder'] = $this->getSelectorHolder();
            $result['holder_event'] = $rule->toggleDisplayEvent($result['initialState']);
            $result['holder_event_opposite'] = $rule->toggleDisplayEvent($result['initialState'], true);
        }

        return (count($result['selectors'])) ? $result : null;
    }
public function formatDisplayRules ( ) { $ holderSelector = $ this -> getSelectorOnly ( ) ; $ result = [ 'targetFieldID' => $ holderSelector , 'conjunction' => $ this -> DisplayRulesConjunctionNice ( ) , 'selectors' => [ ] , 'events' => [ ] , 'operations' => [ ] , 'initialState' => $ this -> ShowOnLoadNice ( ) , 'view' => [ ] , 'opposite' => [ ] , ] ; // Check for field dependencies / default /** @var EditableCustomRule $rule */ foreach ( $ this -> EffectiveDisplayRules ( ) as $ rule ) { // Get the field which is effected /** @var EditableFormField $formFieldWatch */ $ formFieldWatch = DataObject :: get_by_id ( EditableFormField :: class , $ rule -> ConditionFieldID ) ; // Skip deleted fields if ( ! $ formFieldWatch ) { continue ; } $ fieldToWatch = $ formFieldWatch -> getSelectorFieldOnly ( ) ; $ expression = $ rule -> buildExpression ( ) ; if ( ! in_array ( $ fieldToWatch , $ result [ 'selectors' ] ) ) { $ result [ 'selectors' ] [ ] = $ fieldToWatch ; } if ( ! in_array ( $ expression [ 'event' ] , $ result [ 'events' ] ) ) { $ result [ 'events' ] [ ] = $ expression [ 'event' ] ; } $ result [ 'operations' ] [ ] = $ expression [ 'operation' ] ; // View/Show should read $ result [ 'view' ] = $ rule -> toggleDisplayText ( $ result [ 'initialState' ] ) ; $ result [ 'opposite' ] = $ rule -> toggleDisplayText ( $ result [ 'initialState' ] , true ) ; $ result [ 'holder' ] = $ this -> getSelectorHolder ( ) ; $ result [ 'holder_event' ] = $ rule -> toggleDisplayEvent ( $ result [ 'initialState' ] ) ; $ result [ 'holder_event_opposite' ] = $ rule -> toggleDisplayEvent ( $ result [ 'initialState' ] , true ) ; } return ( count ( $ result [ 'selectors' ] ) ) ? $ result : null ; }
Extracts info from DisplayRules into array so UserDefinedForm->buildWatchJS can run through it.
@return array|null
Extracts info from DisplayRules into array so UserDefinedForm - > buildWatchJS can run through it .