[SOLVED] Using Ajax upload: Is it possible to validate whether fileupload is empty or not?

albertzsa

New Member
Hey guys, I'm working on an application form for one of my university project. Things are going well so far, but I just stuck with a problem I can't solve.

I'd like to place several fileupload fields on my form for uploading of some documents. I enabled "Use Ajax upload" to be able to upload multiple files to each item. It works great but I noticed that the notempty validation I applied earlier is not working anymore. It's a big shame, because I get validation errors however all files are uploaded and I cant's submit my form. It works well with the regular file uploader field, but not with Ajax (Plupload).

I tried both the stable and the latest version from GitHub. Is there any workaround for this problem? Any help is appreciated, because it would be really important to prevent people from forgetting to upload their stuff.
 
FYI,
I changed the validate() function in notempty.php to this, because the condition where I check whether the $data object is an array or not was missing.
PHP:
public function validate($data, $repeatCounter)
{
  if (is_array($data))
  {
      $data  = json_encode($data);
  }
 
  $result = ($data == "") ? false : true;
 
  return $result;
}

Now it seems to be working, however I'll subject it to further testing.
 
What was the code on that before your change?

In github, it should call the element model's isConsideredEmpty() method, rather than just testing if $data is empty or not. That looks like the old 3.0 code. The 3.1 code has been this:

PHP:
        $ok = $this->elementModel->dataConsideredEmpty($data, $repeatCounter);
 
        return !$ok;

... for at least a year.

Doesn't work, ind you, but that's what it's been. :)

I'm working on notempty for upload atm.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top