We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Bug report: Phalcon\Forms\Form validation failed

class MyForm extends \Phalcon\Forms\Form
{
    public function initialize() {
        $this->setEntity($this);
        $slug = new Text('slug');
        $slug->setFilters(array('striptags', 'trim'));

        $slug->addValidator( new UniquenessValidator(array(
            'model' => '\MyModel\Post',
            'message' => 'slug exist!'
        )));

        $this->add($slug);
    }
}

When make validation, it throws the below error:

Trying to call method getdi on a non-object
#0 [internal function]: Phalcon\Validation\Validator\Uniqueness->getColumnNameReal('\\MyModel\\P...', 'slug')
#1 [internal function]: Phalcon\Validation\Validator\Uniqueness->isUniqueness(Object(Phalcon\Validation), 'slug')
#2 [internal function]: Phalcon\Validation\Validator\Uniqueness->validate(Object(Phalcon\Validation), 'slug')
#3 [internal function]: Phalcon\Validation->validate(Array, NULL)
#4 ...MyController.php(62): Phalcon\Forms\Form->isValid(Array)
#5 [internal function]: ...
#6 [internal function]: Phalcon\Dispatcher->dispatch()
#7 ...Phalcon\Mvc\Application->handle()
#8 {main}

Bug reports should be posted in Github.



1.7k

Thanks, I will report it in github later.

Bug reports should be posted in Github.