atk4agiletoolkit

validateField doesn't work with models


I want to use validateField with models but it says Method is not defined for this object!

I code like this:

$user_payment=$this->add("Model_Payment");
$user_payment->getField("amount")
                    ->validateNotNull()
                    ->validateField('($this->get())<=0','Please enter a posetive number!');

Solution

  • You are trying to apply ->validateNotNull() to Model. This method should be applied to Field of a Form Like:

    $f = $this->add('Form);
    $f->setModel('Model_YourModel');
    
    $f->getField("amount")
                    ->validateNotNull()....