Why a "None" option in required lookup fields?

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
kevinm
Posts: 10
Joined: 2013-10-31 09:31

Why a "None" option in required lookup fields?

Post by kevinm » 2015-06-03 04:01

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?

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

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

Post by a.gneady » 2015-06-04 10:18

We'll inspect this issue and make a fix for it in the next release.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

kevinm
Posts: 10
Joined: 2013-10-31 09:31

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

Post by kevinm » 2015-06-05 04:54

Many thanks.

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

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

Post by SkayyHH » 2015-06-05 14:56

Hello,

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

Best regards, Kai

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

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

Post by peebee » 2015-06-05 23:04

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.

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

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

Post by SkayyHH » 2015-06-06 20:04

Thanks much!, Kai

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

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

Post by shasta59 » 2015-06-08 01:43

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
Calgary, Alberta, Canada - Using Appgini 5.50 -

kevinm
Posts: 10
Joined: 2013-10-31 09:31

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

Post by kevinm » 2015-09-18 09:33

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.

kevinm
Posts: 10
Joined: 2013-10-31 09:31

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

Post by kevinm » 2015-09-18 09:38

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).

kevinm
Posts: 10
Joined: 2013-10-31 09:31

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

Post by kevinm » 2015-09-18 09:55

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 20319 times
What I would expect to happen is the first valid option to be selected.

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

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

Post by a.gneady » 2015-09-22 11:53

@kevinm, we'll work on fixing this issue in the next release. Thanks for reporting it.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

MsMetaP
Posts: 9
Joined: 2013-05-05 00:30

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

Post by MsMetaP » 2016-01-05 18:03

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?

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

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

Post by shasta59 » 2016-01-05 18:24

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
Calgary, Alberta, Canada - Using Appgini 5.50 -

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

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

Post by shasta59 » 2016-01-05 18:48

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
Calgary, Alberta, Canada - Using Appgini 5.50 -

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

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

Post by a.gneady » 2016-01-06 19:54

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?
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

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

Post by shasta59 » 2016-01-06 20:03

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
Calgary, Alberta, Canada - Using Appgini 5.50 -

MsMetaP
Posts: 9
Joined: 2013-05-05 00:30

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

Post by MsMetaP » 2016-04-22 14:09

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?

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

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

Post by AhmedBR » 2016-04-22 16:10

Yes, this is happening, I reported it to Ahmad as a BUG just a few days ago.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

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

Post by grimblefritz » 2016-04-23 11:11

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.

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

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

Post by AhmedBR » 2016-04-23 13:34

grimblefritz, that is a good workaround till the bug is fixed and easy to code as well ;)
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

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

Post by AhmedBR » 2016-04-23 16:18

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.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

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

Post by grimblefritz » 2016-04-24 14:29

Sounds like a better option than mine. Nice outside the box thinking!

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

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

Post by peebee » 2016-04-27 06:01

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.... :-(

MsMetaP
Posts: 9
Joined: 2013-05-05 00:30

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

Post by MsMetaP » 2016-04-29 13:01

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

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

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

Post by AhmedBR » 2016-04-29 18:07

Glad to hear it helped someone (other than me :lol: ) :D
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

Post Reply