Title: Using select2
Last modified: October 8, 2018

---

# Using select2

 *  Resolved [orodruim](https://wordpress.org/support/users/orodruim/)
 * (@orodruim)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/using-select2-2/)
 * Hello.
    Some months ago I post a question in StackOverflow and you answer giving
   me some clues about what I wanted to do. This is the link: [https://stackoverflow.com/questions/49277808/populate-a-select-from-another-in-wordpress-and-cf7](https://stackoverflow.com/questions/49277808/populate-a-select-from-another-in-wordpress-and-cf7)
 * Now, I am trying to implement what you told me, but I have no idea about to start
   the code.
    I would like to implement a select2 dropdown this way:
 * – Pepper (parent)
    — Red (child) — Yellow (child) — Green (child)
 * – Tomate
    — Cherry (child) — Cocktel (child) — Rama (child)
 * How can I make something like this? The data are in DB (Table Crop, related with
   Table Variety (with a Crop_FK))
 * Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/using-select2-2/#post-10873866)
 * Hey sorry for the late reply, been on the move.
 * In your form you need to create a dynamic drodown field (see [screenshot](https://ps.w.org/cf7-grid-layout/assets/screenshot-16.png?rev=1751953)#
   16). Now for the source of the drodown field options, you have 3 options presented
   to your (in the above screenshot the default Taxonomy Source is visible): ‘Taxonomy
   Source/Post titles/Filter.
 * > The data are in DB (Table Crop, related with Table Variety (with a Crop_FK))
 * so this is where you have to take decision as to how you want to manage this 
   data. If you need to make regular changes to your data (ie add/delete/rename)
   I would recommend to to map it as a WordPress Taxonomy, which you can then use
   as your source in the above field. Note, the change you make to the taxonomy 
   moving fwd will not be synced with you custom tables, if this is required, you
   will need to implement a custom code to do this.
 * On the other hand, if this data is static and does not change much, you can instead
   choose to map the data to your field using a custom filter (the last option in
   the field tag above). You will then need to construct manually your `<option>
   </option>` html tag list using a [custom query]([https://codex.wordpress.org/Class_Reference/wpdb](https://codex.wordpress.org/Class_Reference/wpdb))
   on your tables. In this case to achieve the specific list order, you will need
   to use [option groups](https://select2.org/options#dropdown-option-groups).
 * Hope the above helps.
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/using-select2-2/#post-10875896)
 * I just released an update, along with a new screenshot (#17) on how to use the
   custom filter option to populate your dropdown.
 *  Thread Starter [orodruim](https://wordpress.org/support/users/orodruim/)
 * (@orodruim)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/using-select2-2/#post-10888206)
 * Thanks you for your answer!
    I will test is as soon as i can, and i write you
   again with the results.
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/using-select2-2/#post-10972069)
 * Haven’t heard back from you, so I assuming you either fixed the issue or moved
   on. I am marking this as resolved. In case you still need some help, feel free
   to post a msg below.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Using select2’ is closed to new replies.

 * ![](https://ps.w.org/cf7-grid-layout/assets/icon-256x256.png?rev=1834229)
 * [Smart Grid-Layout Design for Contact Form 7](https://wordpress.org/plugins/cf7-grid-layout/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cf7-grid-layout/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cf7-grid-layout/)
 * [Active Topics](https://wordpress.org/support/plugin/cf7-grid-layout/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cf7-grid-layout/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cf7-grid-layout/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * Last activity: [7 years, 4 months ago](https://wordpress.org/support/topic/using-select2-2/#post-10972069)
 * Status: resolved