Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

ENUM dropdowns?

Post Reply
EcoReality
Posts: 26
Joined: Wed Feb 15, 2017 8:50 am
Location: Salt Spring Island, British Columbia, Canada
Contact:

ENUM dropdowns?

Unread post by EcoReality »

I have a MySQL data model with a number of ENUM types, like "Yes, No" or "kilograms, grams, pounds, ounces" or "hectare, acre, square feet, linear feet", etc.

Is there an easy way to suck these in, or must I manually duplicate them and keep them in sync?

Thanks!
:::: Jan Steinman EcoReality Co-op ::::
EcoReality
Posts: 26
Joined: Wed Feb 15, 2017 8:50 am
Location: Salt Spring Island, British Columbia, Canada
Contact:

Re: ENUM dropdowns?

Unread post by EcoReality »

Okay, I got this far. I defined my dropdown with the following SQL, which puts each ENUM value on a separate line. I have tested this in phpMyAdmin.

Code: Select all

SELECT REPLACE(REPLACE(REPLACE(COLUMN_TYPE, 'enum(''', ''), ''')', ''), ''',''', '\n')
FROM (SELECT COLUMN_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'SSIAA'
AND TABLE_NAME = 'Questionares'
AND COLUMN_NAME = 'Role') x
But when I look at the generated form, the dropdown simply has "undefined" on it.

Do I need to do something else to make it look more like each ENUM value is a separate row, which is what I'm guessing nuBuilder is wanting?
Attachments
Screenshot  2017-02-15 at 19.01.17.png
Screenshot 2017-02-15 at 19.01.17.png (18.93 KiB) Viewed 4442 times
:::: Jan Steinman EcoReality Co-op ::::
EcoReality
Posts: 26
Joined: Wed Feb 15, 2017 8:50 am
Location: Salt Spring Island, British Columbia, Canada
Contact:

Re: ENUM dropdowns?

Unread post by EcoReality »

BUMP!

After looking at literal string examples, I changed the code below so that the ENUM values have vertical bars around them, and tested it in phpMyAdmin. Still no joy.

Help! I've got DOZENS of these, and I really don't want to maintain them separately, let alone copy/paste/edit them all!

It seems to me this would be a commonly used thing. Does no one use ENUMS here?

Thanks in advance for any help offered!
:::: Jan Steinman EcoReality Co-op ::::
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: ENUM dropdowns?

Unread post by admin »

Jan,

I never have.

Steven
EcoReality
Posts: 26
Joined: Wed Feb 15, 2017 8:50 am
Location: Salt Spring Island, British Columbia, Canada
Contact:

Re: ENUM dropdowns?

Unread post by EcoReality »

admin wrote:I never have.
I recommend them for shortish string lists that are unlikely to change. They save complications of external lookup tables for trivial stuff like "Yes/No" items, while leaving the database human-readable in tools like phpMyAdmin. They save time, space, and accuracy over storing strings for things like "Pounds/Kilograms" (or was it "Kilogrammes?" OR "kilograms?")

Downside: no i18n multi-language capability, although you can still key the native ENUM strings into a dictionary of other languages.

I would like to "feature request" this for v4: that you add a new object type "ENUM" that automagically detects ENUM types, creates a drop-down for them, and sets its default value to the SQL default value.

If you can give me a starting point to where to do such a change, I might be able to do it for you.

Your competition (not really!) vFront has them. Here is an example field definition in their form builder:
Attachments
Screenshot  2017-02-19 at 14.30.04.png
Screenshot 2017-02-19 at 14.30.04.png (23.3 KiB) Viewed 4424 times
:::: Jan Steinman EcoReality Co-op ::::
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: ENUM dropdowns?

Unread post by admin »

Jan,

Lists like this can be created in version 3 and will do the same in 4.

http://wiki.nubuilder.net/nubuilderv3/i ... istbox_Tab

Sorry but we have no plans for anything else.

Steven
Post Reply