php - Zend Framework 1.12 - Zend Form File element triggering wrong validation messages -


i have looked through similar answers couldn't find solution.

i have file element in 1 of forms. element defined below.

$file = $this->createelement('file', 'templatefile'); $file->setattrib('id', 'templatefile')      ->setattrib('class', 'form-control')      ->setattrib('placeholder', 'file containing template headers')      ->setlabel('template file <span class="glyphicons glyphicons-sheriffs_star requiredflag"></span>')      ->setrequired(true)      ->addvalidator('notempty', false)      ->addvalidator('count', false, 1)      ->addvalidator('size', false, '1mb')      ->addvalidator("extension", false, array('csv', 'txt'))      ->addfilter('stringtrim');  $file->getvalidator('notempty')->setmessage('please select template file'); $file->getvalidator('count')->setmessage(' please upload 1 file @ time'); $file->getvalidator('size')->setmessage('file exceeds upload limit of 1 mb'); $file->getvalidator('extension')->setmessage('invalid file extension. csv , txt files allowed'); 

i using custom error messages element , causing problems.

when submit form without choosing file rather triggering notempty validation error message see message below.

file 'qhepstow_dblive.sql' exceeds defined form size 

how can trigger following error message when file not selected , avoid once mentioned above?

this error message should displayed when file not selected.

please select template file 

thanks help.

i managed solve problem. hope helps in future.

the problem sequence in adding validators file elemenet.

changing sequence below solved problem.

$file = $this->createelement('file', 'templatefile');         $file->setattrib('id', 'templatefile')             ->setattrib('class', 'form-control')             ->setattrib('placeholder', 'file containing template headers')             ->setlabel('template file <span class="glyphicons glyphicons-sheriffs_star requiredflag"></span>')             ->setdestination($destination)             ->setrequired(true)             ->addvalidator('count', false, 1)             ->addvalidator('notempty', false)             ->addvalidator('size', false, '15mb')             ->addvalidator("extension", false, array('txt' ,'csv'))             ->addfilter('stringtrim'); 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -