Empty field does not validate as required when multiple choise is selected

jdran 30 Oct, 2015
Not really sure if it is a bug.
I have a dropdown selection (i.e. emails) and multiple choice selected. Empty option is passed (i.e. please select recipient).
If somebody does not select a recipient, even though it is required, there is no warning that at least one value is required to be selected.
Debugger reproduction:
Array
(
    [option] => com_chronoforms5
    [chronoform] => contact-form
    [event] => submit
    [onoma] => Test
    [eponumo] => Test
    [epaggelma] => 
    [email] => xxx@xxx.com
    [address] => anAdress
    [num] => 15
    [dimos-tk] => athens
    [tk] => 2342424
    [recipients] => 
    [thema] => Test
    [minuma] => blah blah blah
    [button65] => Submit
    [b5a876s82c12vd496323e223495d2134449e789e5] => 1
    [email_to_use] => xxx@xxxx
    [ip_address] => xx.xxx.xxx.xxx
)
Array
(
)

Errors

Array
(
)


Debug Info

Array
(
    [23] => Array
        (
            [Check Honeypot] => Array
                (
                    [0] => Honeypot check passed.
                )

        )

    [1] => Array
        (
            [Email] => Array
                (
                    [0] => An email with the details below was sent successfully:
                    [1] => To:xxxxxx@xxxxx.com
                    [2] => Subject:Test Form
                    [3] => From name:Test Form
                    [4] => From email:xxxx@xxxxx.com
                    [5] => CC:
                    [6] => BCC:
                    [7] => Reply name:
                    [8] => Reply email:
                    [9] => Attachments:
                    [10] => Array
                        (
                        )

                    [11] => Body:
<table>
<tr><td></td><td></td></tr>
<tr><td>Ονοματεπώνυμο</td><td>test</td></tr>
<tr><td></td><td>test</td></tr>
<tr><td>Επάγγελμα</td><td></td></tr>
<tr><td>Email</td><td>xxx@xxxx.com</td></tr>
<tr><td>Δ/νση Κατοικίας</td><td>Συγγρού</td></tr>
<tr><td></td><td>15</td></tr>
<tr><td>Δήμος / Περιοχη / ΤΚ</td><td>athens</td></tr>
<tr><td></td><td>2342424</td></tr>
<tr><td>Παραλήπτης</td><td></td></tr>
<tr><td>Θέμα Μηνύματος</td><td>test</td></tr>
<tr><td>Μήνυμα</td><td>blah blah blah</td></tr>
</table><br /><br />IP: xx.xxx.xxx.xxx
                )

        )

    [3] => Array
        (
            [Email] => Array
                (
                    [0] => An email with the details below was sent successfully:
                    [1] => To:xxx@xxx.com
                    [2] => Subject:Test Contact Form
                    [3] => From name:Contact Form Tester
                    [4] => From email:xxx@xxx.com
                    [5] => CC:
                    [6] => BCC:
                    [7] => Reply name:
                    [8] => Reply email:
                    [9] => Attachments:
                    [10] => Array
                        (
                        )

                    [11] => Body:
<table>
<tr><td></td><td></td></tr>
<tr><td>Ονοματεπώνυμο</td><td>Test</td></tr>
<tr><td></td><td>Test</td></tr>
<tr><td>Επάγγελμα</td><td></td></tr>
<tr><td>Email</td><td>xxx@xxx.com</td></tr>
<tr><td>Δ/νση Κατοικίας</td><td>anAddress</td></tr>
<tr><td></td><td>15</td></tr>
<tr><td>Δήμος / Περιοχη / ΤΚ</td><td>athens</td></tr>
<tr><td></td><td>2342424</td></tr>
<tr><td>Παραλήπτης</td><td></td></tr>
<tr><td>Θέμα Μηνύματος</td><td>Test</td></tr>
<tr><td>Μήνυμα</td><td>blah blah blah</td></tr>
<p>Ευχαριστούμε για το μήνυμά σας.<p>
                )

        )

)
GreyHead 30 Oct, 2015
Hi jdran,

How exactly is your DropDown set up - if it is a Multiple selection then it needs to have an array name e.g. recipients[] What options do you have set?

Bob
jdran 30 Oct, 2015
it is a simple array in that way:

Field Name + Field ID:
recipients

dropdown Options:
em0=Office 1
em1=Office 2
em2=Office 3
...
em9=Office 10


in Setup I have set up an array for choosing the right office:

<?php
// set a default recipient
$recipient = 'em0';
if ( isset($form->data['recipients']) && $form->data['recipients'] ) {
  $recipient = $form->data['recipients'];
}
$emails = array (
  'em0' => 'xxx@xxx.com',
  'em1' => ' ',
  'em2' => ' ',
  'em3' => ' ',
  'em4' => ' ',
  'em5' => ' ',
  'em6' => ' ',
  'em7' => ' ',
  'em8' => ' ',
  'em9' => ' ' );
$form->data['email_to_use'] = $emails[$recipient];
?>

em1 to em9 deliberately left blank for now.
GreyHead 30 Oct, 2015
Hi jdran,

As i said - a multi-select drop-down needs to have an array name e.g. recipients[] - and the code you have to set the addresses needs to be changed to work with multiple addresses.

That said, I cannot see why the value of recipients is empty in the Debugger output.

Please post a link to the form so I can take a quick look.

Bob
This topic is locked and no more replies can be posted.