Jump to content

Pricings Model getRules()


Blesta Addons

Recommended Posts

the function in the model is not returning the rules set,

    private function getRules($vars)
    {
        $rules = [
            'term' => [
                'format' => [
                    'if_set' => true,
                    'pre_format' => [[$this, 'formatTerm'], ['_linked' => 'period']],
                    'rule' => 'is_numeric',
                    'message' => $this->_('Pricings.!error.term.format')
                ],
                'length' => [
                    'if_set' => true,
                    'rule' => ['maxLength', 5],
                    'message' => $this->_('Pricings.!error.term.length')
                ],
                'valid' => [
                    'if_set' => true,
                    'rule' => [[$this, 'validateTerm'], ['_linked' => 'period']],
                    'message' => $this->_('Pricings.!error.term.valid')
                ]
            ],
            'period' => [
                'format' => [
                    'if_set' => true,
                    'rule' => [[$this, 'validatePeriod']],
                    'message' => $this->_('Pricings.!error.period.format')
                ]
            ],
            'price' => [
                'format' => [
                    'if_set' => true,
                    'pre_format' => [[$this, 'currencyToDecimal'], ['_linked' => 'currency'], 4],
                    'rule' => 'is_numeric',
                    'message' => $this->_('Pricings.!error.price.format')
                ]
            ],
            'setup_fee' => [
                'format' => [
                    'if_set' => true,
                    'pre_format' => [[$this, 'currencyToDecimal'], ['_linked' => 'currency'], 4],
                    'rule' => 'is_numeric',
                    'message' => $this->_('Pricings.!error.setup_fee.format')
                ]
            ],
            'cancel_fee' => [
                'format' => [
                    'if_set' => true,
                    'pre_format' => [[$this, 'currencyToDecimal'], ['_linked' => 'currency'], 4],
                    'rule' => 'is_numeric',
                    'message' => $this->_('Pricings.!error.cancel_fee.format')
                ]
            ],
            'currency' => [
                'format' => [
                    'if_set' => true,
                    'rule' => ['matches', '/^(.*){3}$/'],
                    'message' => $this->_('Pricings.!error.currency.format')
                ]
            ]
        ];
    }

 

i think it should have in the end a

        return $rules;

 

Link to comment
Share on other sites

  • Tyson locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...