Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Enumeration Field with Multiselect 07 Jul 2016 08:27 #14174

Hi,

Is it possible to select multiple values within a simple Enumeration field?

Perhaps the multiple values would be stored in a single table record as comma delimited?
Just call me Chris :)

Please Log in or Create an account to join the conversation.

Enumeration Field with Multiselect 07 Jul 2016 10:15 #14176

Nope.

An enumeration filed corresponds with the mysql enum field, it can only have 1 value.
The following user(s) said Thank You: organicwebs

Please Log in or Create an account to join the conversation.

Enumeration Field with Multiselect 25 Jul 2016 11:07 #14322

Perhaps this post should be moved to "New functionalities"

What I proposed would have one value. The multiple values could be stored in a single table record as comma delimited (or choose your deliminator).

I need to create a form with ~10 multi-selected fields (with, say, 4 options). Creating 10 tables for this purpose is a little crazy - and then loading all these tables with basic data after every install is also crazy.

For now I will have to create ~40 Boolean fields to do this. :whistle:

No rush for me, I can get by for now.

Cheers
Just call me Chris :)

Please Log in or Create an account to join the conversation.

Enumeration Field with Multiselect 25 Jul 2016 13:03 #14324

Hello Chris

Sounds as if you can use a single cook JSON field to achieve what you are working on (see below).
{
  "options": {
    "Apples": "yes",
    "Oranges": "yes",
    "Cherries": "no",
    "Cranberries": "yes",
    "Strawberries": "yes",
    "Watermelon": "no"
  }
}


You can then convert it to and object and code your interface to update its properties.
if (!empty($item->options) && is_string($item->options))
{
	$registry = new JRegistry;
	$registry->loadString($item->options);
	$item->options = $registry->toObject();
}

Good luck
vlemos
The following user(s) said Thank You: organicwebs

Please Log in or Create an account to join the conversation.

Enumeration Field with Multiselect 25 Jul 2016 19:44 #14326

You can certainly do the JSON field, but would it not be better to use the rather awesome Joomla multi-select functionality

www.j-cook.pro/index.php/r/relations

This allows multiselects done pro style 1:n (on the above link scroll down to FORMS to see the finished article, multiselects with live searching for large tables

Better database design overall (IMO)
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The following user(s) said Thank You: admin, organicwebs

Please Log in or Create an account to join the conversation.

Enumeration Field with Multiselect 25 Jul 2016 20:31 #14329

When using a select field to parse the json, you will also have the mulitiselects, because cook uses chosen on select fields.
Personally I think that an enumeration field should be what it is, directly mapped to the enum mysql field, allowing just 1 value :)

Please Log in or Create an account to join the conversation.

Enumeration Field with Multiselect 25 Jul 2016 21:07 #14332

I agree Morgan, less coding + less effort = no brainer = brilliant. . . .

Please Log in or Create an account to join the conversation.

Field with Multiselect 16 Aug 2016 11:28 #14446

Thankyou for the suggestions and your time.

OK - forget my reference to the term "Enumeration". Maybe a new data type/wizard is needed.

The JSON field is not filterable - correct? I need that so the user can search for both "Apples" and "Oranges" - but not "Strawberries".

To use relational tables, for every Multi-selection field I would need to create 2 additional tables - correct? (Have I been doing this wrong?)

I would have to ask the user to populate these multi-selection tables. This not so good if there is custom code looking for specific values.

Example. Say, its a New Car ordering form. (I'm building something else - but just for simplicity...).

In a table "Car"...
  • "Options" column - values to be multi-selectable "Window Tint", "Towball", "Roof rack"
  • "Radio" column - values to be multi-selectable "FM" "AM" "CD" "USB" Bluetooth"
  • "Drive" column - values to be multi-selectable "Front Wheel Drive", "4WD", "Rear Wheel Drive" (my car is both 4WD and Rear).
  • "Airbags " column - values to be multi-selectable "Driver" "Passenger", "Side"

These are not large tables.

The developer defines these values in the JCook Builder. The Dealer fills in the car data. The Buyer searches the data to find the car they want.

Say there is more functionally - like a banner add pops up for Bluetooth devices when the user is searching for a car with "Bluetooth". So the Developer needs to hard set these values.

Creating a single table for these 4 basic multi selection fields is neat and simple. Creating 9 tables (if I understand relational tables correctly) is nuts.

For now, to do this I'm using Boolean data type. So instead of 4 Multi selections, I'm creating 14 Boolean.

Filtering is required. So if an end user is looking for "Bluetooth", they can find cars with Bluetooth.
(I don't think manually editing JASON to achieve the multi-select will achieve this)
Just call me Chris :)

Please Log in or Create an account to join the conversation.

Last edit: by organicwebs. Reason: change title

Field with Multiselect 16 Aug 2016 16:40 #14455

Yes, you have to add 2 tables, but you can fill them in the builder and then check "include dataset" so the user does not have to enter it but still has the flexibility to edit.
If you do not want the user to be able to edit, you can fork the model in such a way that editing/adding is only allowed for super-users (or another user)

I also think custom code should never need hard coded values, there is almost always a generic solution :)

But as with all: you can build it anyway you want with Cook!
The following user(s) said Thank You: organicwebs

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.071 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started