Page 1 of 1
ENUM dropdowns?
Posted: Wed Feb 15, 2017 8:54 am
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!
Re: ENUM dropdowns?
Posted: Thu Feb 16, 2017 4:03 am
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?
Re: ENUM dropdowns?
Posted: Fri Feb 17, 2017 1:29 am
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!
Re: ENUM dropdowns?
Posted: Sun Feb 19, 2017 10:24 pm
by admin
Jan,
I never have.
Steven
Re: ENUM dropdowns?
Posted: Sun Feb 19, 2017 11:35 pm
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:
Re: ENUM dropdowns?
Posted: Mon Feb 20, 2017 9:46 pm
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