Page 1 of 1

Why a "None" option in required lookup fields?

Posted: 2015-06-03 04:01
by kevinm
Hi All, I've just updated to 5.4. I was using 5.1 before and if a lookup field was designated as required, there was no blank option at the top of the dropdown list. Now there doesn't seem to be any way of disabling this.

It doesn't make sense to have a blank, or "None", option for a required field, and it means an extra down keystroke or a mouse click after typing your search keys, to get past it which is a nuisance.

Is there really no way to exclude "None" from these dropdown lists now?

Re: Why a "None" option in required lookup fields?

Posted: 2015-06-04 10:18
by a.gneady
We'll inspect this issue and make a fix for it in the next release.

Re: Why a "None" option in required lookup fields?

Posted: 2015-06-05 04:54
by kevinm
Many thanks.

Re: Why a "None" option in required lookup fields?

Posted: 2015-06-05 14:56
by SkayyHH
Hello,

i need a blank option :-) Or an blank entry like "select". But with translation option for "select".

Best regards, Kai

Re: Why a "None" option in required lookup fields?

Posted: 2015-06-05 23:04
by peebee
i need a blank option :-) Or an blank entry like "select". But with translation option for "select".
Simple solution could be to edit this translation string:

$Translation['none'] = 'None';
to $Translation['none'] = 'Select';

in language.php That should achieve the desired effect. That will however change all instances of "None" including radio buttons.

If you want to be more specific; look for the translation string $Translation['none'] in ajax_combo.php (starts around line 210) and in combo.class.php (line 99) and edit that code to suit.

Re: Why a "None" option in required lookup fields?

Posted: 2015-06-06 20:04
by SkayyHH
Thanks much!, Kai

Re: Why a "None" option in required lookup fields?

Posted: 2015-06-08 01:43
by shasta59
Using 5.31

Not sure if this is what you are looking for but what I do to get rid of the none is add the following line to the yourtable_dml.php file. This is added as a new line just above the //combobox: fieldname for the next combobox. I usually put it below the line:

$combo_yourfieldname->SelectName = 'yourfieldname';

$combo_yourfieldname->AllowNull = false;

I then no longer get the None showing up. If you want it to show up change false to true.

Have been using this for a long time. I actually have it as one of the options on my setting page I made in the admin section. This way I can turn it on and off easily without having to go in and change the code each time. Just change a setting. Means putting in other code to look at this setting but that is minor. It means I no longer use the code above but it does the same thing.

If you have any questions or it is not clear ask away.

Alan

Re: Why a "None" option in required lookup fields?

Posted: 2015-09-18 09:33
by kevinm
Alan,

I tried this but without success - I'm still getting the 'None' option in the drop down. I'm using v5.42, perhaps that changes things?

It's not a huge deal, but would be nice not to have to jump over the extra option each time.

Kevin.

Re: Why a "None" option in required lookup fields?

Posted: 2015-09-18 09:38
by kevinm
SkayyHH wrote:Hello,

i need a blank option :-) Or an blank entry like "select". But with translation option for "select".

Best regards, Kai
Yes, understood, if the field is not designated as 'Required', then a blank option would be valid (and necessary).

Re: Why a "None" option in required lookup fields?

Posted: 2015-09-18 09:55
by kevinm
This is an example of the behaviour I am seeing: in a drop down for the category field, that is a required field, I start typing "a", then "b" and this is the result...
example.JPG
example.JPG (18.41 KiB) Viewed 24072 times
What I would expect to happen is the first valid option to be selected.

Re: Why a "None" option in required lookup fields?

Posted: 2015-09-22 11:53
by a.gneady
@kevinm, we'll work on fixing this issue in the next release. Thanks for reporting it.

Re: Why a "None" option in required lookup fields?

Posted: 2016-01-05 18:03
by MsMetaP
It doesn't look like this was fixed in 5.5 which I just purchased? I have the same problem with "None" showing up in Lookup Fields. :cry:

I also have another problem. I have an options list, that's also a required field. Since the list defaults to the first item, users are not "forced" to choose the correct option. They can end up with the same first item in the list each time because there's "something" in the required field.

How do I force them to "choose" rather than going with the default?

Re: Why a "None" option in required lookup fields?

Posted: 2016-01-05 18:24
by shasta59
Hello All

Using version 5.5 (testing phase only right now - not a live run)

I will run an output using the latest release and see if I can figure out a quick solution. As I use this all the time it is important to me to have this working also. Again, the alligators are snapping at my **s right now but I will try to find some time to have a look.

Alan

Re: Why a "None" option in required lookup fields?

Posted: 2016-01-05 18:48
by shasta59
Using version 5.5

Actually it is working fine for me. The only issue I am getting is I cannot turn it off and get the None option now. But I will track that one down. I downloaded the 5.5 this AM (had beta before) and it is all good. I am going to experiment and see what I can find and I will advise the group.

Alan

Re: Why a "None" option in required lookup fields?

Posted: 2016-01-06 19:54
by a.gneady
In AppGini 5.50, the 'None' option is not shown in drop-downs if the field is set as 'Required'. Otherwise, it should be displayed. Are you seeing a different behavior?

Re: Why a "None" option in required lookup fields?

Posted: 2016-01-06 20:03
by shasta59
I am seeing interesting behaviour on this and am trying to figure it out. On one database, an existing one, with the code in place to not show it it does not show. When I create a brand new empty database, using the same files generated by 5.5 it shows up. The only real difference is in which database the app is pointed at. This makes no sense to me. I am in the process of setting up a brand new testing server to see if the behaviour follows the code or the database or some other factor.

I am working on this to see why this is going on and trying to setup a replication of this. I will also test the required aspect for the field and advise of what I find.

I have dumped all caches etc. I am also setting up a brand new fresh install of software on a clean hard drive so I am working from clean copies of everything. More of a puzzle to solve - a challenge. It will most likely be something silly and small. But I will advise what I find.

Alan

Re: Why a "None" option in required lookup fields?

Posted: 2016-04-22 14:09
by MsMetaP
Did this issue ever get addressed? I have created a brand new database in 5.5. I have several look up fields and one is a required field. The user is NOT forced to choose an item from the list. It simply accepts the first choice in the Parent Table which means setting it to required is useless. Having this required field is VERY important for this database. I need a work-around at the least, please?

Re: Why a "None" option in required lookup fields?

Posted: 2016-04-22 16:10
by AhmedBR
Yes, this is happening, I reported it to Ahmad as a BUG just a few days ago.

Re: Why a "None" option in required lookup fields?

Posted: 2016-04-23 11:11
by grimblefritz
A possible workaround. Define the first option as something invalid. This would be the "default" if the user takes no action. Then in the before hooks, validate against this invalid option. The end result will be that the user might forget to set the value, but they won't be able to save until they do select one.

Re: Why a "None" option in required lookup fields?

Posted: 2016-04-23 13:34
by AhmedBR
grimblefritz, that is a good workaround till the bug is fixed and easy to code as well ;)

Re: Why a "None" option in required lookup fields?

Posted: 2016-04-23 16:18
by AhmedBR
I found another work around without programing:
Set the default value of the field to something not in the list.

This will do the trick as well.

Re: Why a "None" option in required lookup fields?

Posted: 2016-04-24 14:29
by grimblefritz
Sounds like a better option than mine. Nice outside the box thinking!

Re: Why a "None" option in required lookup fields?

Posted: 2016-04-27 06:01
by peebee
Agreed that defaulting to the first option on the lookup dropdown list when the field is required is a problem. High potential to save a record with the incorrect data as the field has been overlooked by the User but it has been accepted as not null - as the default (first option) is automatically selected and recorded.

I found that you can fix the problem by editing this code near the bottom of ajax_combo.php

Code: Select all

if(empty($prepared_data) && $page == 1 && !$search_id && !$field['not_null']){
					$prepared_data[] = array('id' => empty_lookup_value, 'text' => "<{$Translation['none']}>");
}
to this (just remove && !$field['not_null'] )

Code: Select all

if(empty($prepared_data) && $page == 1 && !$search_id){
					$prepared_data[] = array('id' => empty_lookup_value, 'text' => "<{$Translation['none']}>");
}
It doesn't seem to do any hidden damage and returns the <None> option to the top of the dropdown, forcing the User to select an option. Of course, it won't save the <None> as an option and returns a "required field" error, as it should. I used the language file to translate <None> to <Pending> or whatever you feel may look better than <None>.

The only downside that I can see (albeit as petty as it is) is that in the event you do NOT select one of the required dropdowns, rather than a convenient modal "required field" error, it loads a new page with the error and a "back" link. Of course if you have just entered a large amount of data but have forgotten to complete a required field and have to click the "back" link, everything you have just entered is gone and you have to start again.... :-(

Re: Why a "None" option in required lookup fields?

Posted: 2016-04-29 13:01
by MsMetaP
AhmedBR wrote:I found another work around without programing:
Set the default value of the field to something not in the list.

This will do the trick as well.
Thanks Ahmed! This works perfectly. Solved my problem and boss is now happy. :D

Re: Why a "None" option in required lookup fields?

Posted: 2016-04-29 18:07
by AhmedBR
Glad to hear it helped someone (other than me :lol: ) :D