mandatory description field using java? mandatory description field using java?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

mandatory description field using java?

Started by crl, February 22, 2012, 01:49:54 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

crl

I have a problem with gallery users not adding information to the description field when uploading their own images, thjs field needs to be made mandatory.  There is a similar old thread using a java script, unfortunately it'd for version 1.3 http://forum.coppermine-gallery.net/index.php/topic,20965.0.html  is there a similar script for 1.5?

Αndré

As JavaScript (not Java!) is client-sided it's no reliable way to make a field mandatory. However, as the flash uploader first adds the files to the gallery and the meta album is added later, the only way to make the description field mandatory is to disable the flash uploader for your users and only provide the single HTML upload form. Is this suitable for your gallery?

crl

There's no problem disabling the flash uploader and jut use the single HTML uploader.  If I go along this route how do I then make the description field mandatory?

Αndré

To reject pictures without a file description, open db_input.php, find
    // Test if the filename of the temporary uploaded picture is empty
    // getRaw is safe here since this filename is generated by the server
    if ($superCage->files->getRaw("/userpicture/tmp_name") == '') {
        cpg_die(ERROR, $lang_db_input_php['no_pic_uploaded'], __FILE__, __LINE__);
    }

and below, add
    if (trim($superCage->post->getRaw("caption")) == '') {
        cpg_die(ERROR, 'You need to enter a file description', __FILE__, __LINE__);
    }

crl


Aero2012

Does this work for Custom Fields too? If not, how may I may Custom Fields Mandatory?

Thanks in Advance -

Αndré

To make user field 1 mandatory, use something like
    if (trim($superCage->post->getRaw("user1")) == '') {
        cpg_die(ERROR, 'Your error message here', __FILE__, __LINE__);
    }

and so on...

Aero2012