• Resolved kingsdavid

    (@kingsdavid)


    In my form, depending on the age of the user, the email field is mandatory or optional.
    So I created a condition to display the mandatory or optional fields depending on the age.

    [checkbox eleve use_label_element exclusive “Mineur ” “Majeur”]

    [group elevemineur]
    Email : [email email]
    [/group]

    [group elevemajeur]
    Email* : [email* email]
    [/group]

    The display works correctly but the code does not work, the email field is considered optional regardless of the age chosen (minor or adult).

    The asterisk () of [email email] is not taken into account.

    Of course, I can create two different names email_minor and email_major but I need to have a single item for display in a single column of a table afterwards.

    Do you have an idea to solve this problem?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the website in question?

    Thread Starter kingsdavid

    (@kingsdavid)

    Hello, here is the website page. You’ll see that the display works correctly when you choose Mineur or Majeur but the asterisk (*) in [email* email] is not taken into account, the message is still sent.

    https://www.embba.fr/test2/

    AW

    (@geykgn)

    Hi,
    @kingsdavid you have two fields with the same name. Isn’t it so that the first one is taken for verification, which is optional in your case? You change the order of the fields and you check.

    Thread Starter kingsdavid

    (@kingsdavid)

    Yes I know.
    I need the fields to have the same name because the mail will then need to appear in a single column of a tablesome or flamengo table.

    If I change the order, it’s the same result. The form is sent.

    If I put two different names email1 email2, tablesome or flamengo will display them in two separate columns. Since I have many more fields than Email, this will make a very long and unreadable table

    • This reply was modified 2 years ago by kingsdavid.
    • This reply was modified 2 years ago by kingsdavid.
    Plugin Author Takayuki Miyoshi

    (@takayukister)

    What other plugins and theme do you use on the site?

    Thread Starter kingsdavid

    (@kingsdavid)

    Here the entire plugin list :

    – Conditional Fields for Contact Form 7
    – Contact Form 7
    – Disable Comments RB
    – Everest Gallery Lite
    – Honeypot pour Contact Form 7
    – MailPoet
    – Photo Gallery
    – Simple CSS
    – SpiceBox
    – TablePress
    – Tablesome
    – The Events Calendar
    – Ultimate Social Media PLUS
    – Yoast SEO

    The theme is Bravada

    • This reply was modified 2 years ago by kingsdavid.
    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Try switching to the default theme, deactivating all plugins excluding Contact Form 7 and Yoast SEO, and clearing all cache data.

    Why you are advised to deactivate plugins and switch to the default theme.

    Thread Starter kingsdavid

    (@kingsdavid)

    I’ll try. Of course I also have to exclude Conditional Fields for Contact Form 7 plugin, otherwise I won’t do the test to know if the condition works, is that right?

    If you ask me to test without plugins and with the default theme, does that mean that normally the script should work?

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    I also have to exclude Conditional Fields for Contact Form 7 plugin

    No, deactivate that plugin.

    Thread Starter kingsdavid

    (@kingsdavid)

    I don’t understand: if I deactivate this plugin (Conditional Fields for Contact Form 7), the code no longer makes sense. There are no more group, no more conditions, there are two fields left with the same name, with the only difference being one optional and the other mandatory .

    I tried anyway with the default theme and with the current theme, deactivating all plugin excluding Contact Form 7 and Yoast SEO, and clearing all cache data → the result is that both are considered mandatory, whatever the order of the fields.

    [checkbox eleve use_label_element exclusive “Mineur ” “Majeur”]

    [group elevemineur]
    Email : [email email]
    [/group]

    [group elevemajeur]
    Email* : [email* email]
    [/group]

    AW

    (@geykgn)

    Hi,
    Wouldn’t a more appropriate approach be to define one non-mandatory email field and use a custom validator for that field (Custom validation)?
    The group can be used to control the label for this field ??.
    Something like:

    [checkbox eleve use_label_element exclusive “Mineur ” “Majeur”]
    
    <label>Email
    [group elevemajeur]*[/group] : [email email]
    </label>

    PS. I don’t know the Conditional Fields for Contact Form 7 plugin.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Now you understand that it is the Conditional Fields for Contact Form 7 plugin’s problem. Post it to their support forum instead of here.

    Welcome to Support Forum — Please Read Before Posting

    Thread Starter kingsdavid

    (@kingsdavid)

    Ok, thanks for your help
    I will post on the forum and let you know.

    • This reply was modified 2 years ago by kingsdavid.
Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Conditional field problem’ is closed to new replies.