Support » Plugin: Contact Form 7 - Conditional Fields » Contact Form 7 – Conditional Fields, multiple state-fields, empty result

  • Resolved supersepp108

    (@supersepp108)


    My problem is, that I am having 3 different drop-downs for the “state”-field.
    All states of India, USA and Brazil. Dependend on the selection of “Country” a dropdown for “State” is shown.

    Since I am having 5 times a state-field in the email-section of contact-form 7. Its not parsing, respectively delivering an empty field in the email received. It’s working if I name the state-fields differently, but then I will have 3 (dependent on the number of state-fields) different state-columns in my database. I only would like to have ONE state-field in my database.

    Any Idea? Help is much appreciated, Thank you!!

    The logic:

    show [group-States-empty] if [Country] equals ""
    show [group-States-random] if [Country] not equals ""
                           and if [Country] not equals "Brazil"
                           and if [Country] not equals "USA"
                           and if [Country] not equals "India"
    show [group-State-Brazil] if [Country] equals "Brazil"
    show [group-State-India] if [Country] equals "India"
    show [group-States-US] if [Country] equals "USA"

    This sequence results in an empty field “State”.

    Sequence in Email:

    [group-States-US][State][/group-States-US]
    [group-State-India][State][/group-State-India]
    [group-State-Brazil][State][/group-State-Brazil]
    [group-States-empty][State][/group-States-empty]
    [group-States-random][State][/group-States-random]

    ~~~~~~~

    This also results in empty fields

    [group]
    [group-States-US][State][/group-States-US]
    [group-State-India][State][/group-State-India]
    [group-State-Brazil][State][/group-State-Brazil]
    [group-States-empty][State][/group-States-empty]
    [group-States-random][State][/group-States-random]
    [/group]

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • There is a rule which is mandatory to consider – All fields should be unique – but which leads to multiple columns in the database.
    https://conditional-fields-cf7.bdwm.be/docs/troubleshooting/all-field-names-should-be-unique/

    What can I do if I will define a conditional set where its result is written in only in 1 table-column in my database?

    E. G. If dependend on country-selection a state dropdown should be displayed.
    In fact I have multiple state-dropdowns, but only 1 will be displayed, depended no the “Country”-selection. And, it makes only sense to me, if I can write the result in 1 table-Column “State” in my database.

    Plugin Author Jules Colle

    (@jules-colle)

    Short answer, you can’t. The fields in your forms are actual fields and each field needs a unique name.

    So the only thing you could do it make sure that there is only one state field, and show this field only if you need it, instead of creating it 3 times.

    Of course the limitation with this is that it gets more complex if the text in the group needs to be different.

    While I do understand your use case and I realize this is a limitation of the plugin, it is important to note that the plugin should work for a large variety of use cases. So I cannot simply allow the same field names inside groups and assume that only the visible fields should be submitted. Although I am thinking about allowing fields with the same name in the PRO version, after adding an option to only submit the visible fields, this will not land in the free version, because I’m afraid people will not understand how it works and this support forum is going to explode 🙂

    Thank you for your fast reply.

    In fact there is currently no flexible solution for non-programmers outside.
    I will have a lot of countries each with different states. But there is no sense to have multiple data-base-columns/states dependent on the country selected.
    And, for sure, the demand having a form where you can select countries and in dependence you like to show states is quite wide-spread.
    I assume there is a common agreement in this fact.

    I would use the pro-version if it provides a solution for this demand. I guess a lot of CF7 users would be happy about that.

    Looking to hear from you. At the moment I don’t know how to proceed.
    Thank you!

    Plugin Author Jules Colle

    (@jules-colle)

    OK, I have added it to my TODO: https://github.com/pwkip/contact-form-7-conditional-fields/issues/65

    We can follow up there. I’ll close this one.

    Great, Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.