Add extra field on contact form

Hi
I am using the contact form plugin, and would like to add an extra checkbox field.

I have attempted this by repeating the structure of the code for the other fields wherever it appears on the contact_form.php and contact form/form.php files...
The field is showing on the form, but the value does not get retained at the confirm stage and does not show in the email.

Does anybody know if this is possible, and can help me out?
thanks

Comments

  • acrylian Administrator, Developer
    Well, you need to change the functions that process the POST on the form also. But what field do you need actually? There are really quite a bunch available?
  • Thanks for your reply!
    I would like to add a checkbox field "Would you like to receive our newsletter?"
    The fields available at the moment are all text fields and my clumsy attempts at adapting the code have not been successful...
  • acrylian Administrator, Developer
    If you really plan a newsletter I would recommend to use one of the many newsletter scripts available where users can sign in and sign out themselves. That is more convenient for you and your users (and depending on your local laws probably better as well.)
  • Yes we do have a newsletter sign up box as well, but we would like to have the checkbox on the contact form too... if possible!
  • acrylian Administrator, Developer
    Well, possible it is for sure, it's just code.
  • Yes that's what I thought... But if I take the exact code of one of the other fields and change the input type from 'text' to 'checkbox' the information does not get carried through to the confirm stage or the email.

    Does anybody have any pointers as to what I'm doing wrong?
    I'm sure it's probably quite obvious but I just can't figure it out...

    thanks for any help!
  • What exactly have you edited so far? You will need to change both `zp-core/zp-extensions/contact_form.php` and `zp-core/zp-extensions/contact_form/form.php` to add a new checkbox. Sounds like you have not edited `contact_form.php` correctly to carry the checkbox's info through POST.
  • After trying various things, I have now basically tried to adapt the 'company' field which was not being used in the form.
    On the /contact_form/form.php file I have changed the input type to checkbox. All other references to the company field remain the same.
    As this is now a checkbox and not a textfield, I know I must need to adapt more code than this to carry the information through correctly, but I don't know what.. can you possibly give me any ideas?
    thanks
  • The thing about checkboxes is that they appear as part of the POST result ONLY if they are checked. So you will need to test if the $_POST['company'] (or whatever) field exists. If it does, the box was checked, if it does not, the box was not checked.
  • Thank you so much for pointing me in the right direction!

    As a reference to anyone else who might want to include a checkbox on the contact form, I turned the 'company' field into a checkbox using the following code:

    ` value="yes"<?php if ($_processing_post) echo ' DISABLED'; ?> />`
  • The current format ("size:media=XX.YY") does not permit any spaces. But How can I include spaces if I desire? Such as in the 'size' or 'media' section? Perhaps a better format can be pure colon delimited, such as

    size:some text here includes spaces:XX.YY size2:more text:ZZ:AA

    And the normal <space>s between elements. One of my clients would like to have the following showing correctly:

    5x7:Glossy and Matte=19.95

    But the spaces break stuff (and hyphens look ugly).

    Or, what about just regular strings, such as

    "5x7 Glossy and Matte":19.95 "next time here":32.99

    thoughts?
  • acrylian Administrator, Developer
    About what are you asking actually? This has surely nothing to do with the contact form....
  • Oh sh*t - wrong forum ! =(
Sign In or Register to comment.