[SOLVED] Make country field mandatory

Moderator: crythias

Locked
HervE
Znuny wizard
Posts: 391
Joined: 03 Jan 2011, 17:15
Znuny Version: 3.3.8
Location: France

[SOLVED] Make country field mandatory

Post by HervE »

Hello,

I have transformed Country field of CustomerUser into a list (see http://forums.otrs.org/viewtopic.php?f=61&t=7721#p30634).

But now I want it to be mandatory.
Of course I set the 'required' property to 1 for 'UserCountry' in the Map of Config.pm.

But this doesn't make it, because the creation of a new CustomerUser has '-' as default value for Country... which is a value!

I guess if I remove it from the list, the first element will do it instead... and all my CustomerUsers will be created with 'Afghanistan' as default :-|

Finally my only question is the following:
Is it possible to have a list field with no default value, and how?

Regards,
HervE
Last edited by HervE on 27 Jan 2011, 18:00, edited 1 time in total.
OTRS 3.3.8 - Windows 7 - IIS7 - SQL Server - Firefox 30
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Make country field mandatory

Post by crythias »

In Config.pm, did you create the section:

Code: Select all

        Selections => {

            UserCountry => {
                'blank' => '',
                'US' => 'US',
                'DE' => 'DE',
            },
        },
within $Self->{CustomerUser}? I don't see in the code where PossibleNone is set for this purpose, so it shouldn't (as far as I can tell) put a "-" as an option.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
HervE
Znuny wizard
Posts: 391
Joined: 03 Jan 2011, 17:15
Znuny Version: 3.3.8
Location: France

Re: Make country field mandatory

Post by HervE »

Thanks for your answer.

Yes, I did create this section:

Code: Select all

        Selections => {
            UserCountry => {
                'blank'                          => '',
                '-'                              => '-',
                'Afghanistan'                    => 'Afghanistan',
                'Albania'                        => 'Albania',
                'Algeria'                        => 'Algeria',
within $Self->{CustomerUser}.

It appears that the blank value ('') still is a value. So the form doesn't tell me I forgot to fill in this field when I submit.
PossibleNone = false would be nice, where is it set?
How to do otherwise?

Regards,
HervE
OTRS 3.3.8 - Windows 7 - IIS7 - SQL Server - Firefox 30
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Make country field mandatory

Post by jojo »

try

Code: Select all

''                              => '-',
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
HervE
Znuny wizard
Posts: 391
Joined: 03 Jan 2011, 17:15
Znuny Version: 3.3.8
Location: France

Re: Make country field mandatory

Post by HervE »

Yes, you are right.
'' is not a value, but '-' is.

HervE
OTRS 3.3.8 - Windows 7 - IIS7 - SQL Server - Firefox 30
Locked