Title: Adding CUSTOM DEPENDENCIES
Last modified: October 26, 2021

---

# Adding CUSTOM DEPENDENCIES

 *  Resolved [plamenyordanovdev](https://wordpress.org/support/users/plamenyordanovdev/)
 * (@plamenyordanovdev)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/adding-custom-dependencies/)
 * Hi there,
 * we have a very simple form of doing calculations based on colors and sizes.
 * We sell products and we’ll be using your plugin for this.
 * Some of our products have different sizes. Those sizes have X, Y, Z colors available.
 * However, the bigger sizes have different colors available.
 * How can we make a dependency so that when someone chooses a size A, he got to
   then choose only between certain colors?
 * Thanks!

Viewing 1 replies (of 1 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/adding-custom-dependencies/#post-15006862)
 * Hello [@plamenyordanovdev](https://wordpress.org/support/users/plamenyordanovdev/)
 * You have multiple alternatives to display or populate the correct color list 
   based on the size selected. The option to use depends on your copy of the plugin.
 * Using the Free and Professional versions of the plugin:
 * * First alternative: Insert multiple dropdowns or radio button fields with the
   list of colors, one per size. And define these new fields as dependent on the
   corresponding size choice in the dropdown or radio buttons for sizes. For example,
   assuming you have sizes: S, M, L, and XL, you might need four dropdown files 
   for the colors. More information about dependencies by reading the following 
   blog post:
 * [https://cff.dwbooster.com/blog/2020/03/01/dependencies](https://cff.dwbooster.com/blog/2020/03/01/dependencies)
 * Handicap, you need multiple fields for colors.
 * * Second alternative: Populate the colors list by programming. In this case, 
   you need only one field for colors and a calculated field as an auxiliary to 
   populate the colors choices. For example, assuming the size list is the fieldname123,
   and the colors list the fieldname321, the equation in the calculated field could
   be similar to:
 *     ```
       (function(){
           var texts = [], values = [];
           switch(fieldname123)
           {
               case 'S':
                   texts = ['blue','red'];
                   values = ['blue','red'];
               break;
               case 'M':
                   texts = ['blue','red','white'];
                   values = ['blue','red', 'white'];
               break;
               case 'L':
                   texts = ['brown','yellow'];
                   values = ['brown','yellow'];
               break;
               case 'XL':
                   texts = ['black','red'];
                   values = ['black','red'];
               break;
           }
           getField(321).setChoices({texts:texts, values:values});
       })()
       ```
   
 * Handicap, you must edit the equation for every variation of size or color.
 * Using the Developer and Platinum versions of the plugin:
 * It is my preferred alternative because it allows me to update sizes and colors
   without touching the form.
 * You can create a CSV file with pairs of size-color. Furthermore, to create, edit
   and maintain the CSV file, you can use Google Sheet. For example:
 * size,color
    S,blue S,red M,blue M,red M,white L,brown L,yellow XL,black XL,red
 * And then insert two DropDown DS fields in the form to get the sizes and colors
   from the CSV file.
 * More information about the DS fields by reading the following blog post:
 * [https://cff.dwbooster.com/blog/2019/02/14/ds/](https://cff.dwbooster.com/blog/2019/02/14/ds/)
 * Best regards.

Viewing 1 replies (of 1 total)

The topic ‘Adding CUSTOM DEPENDENCIES’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/adding-custom-dependencies/#post-15006862)
 * Status: resolved