Jump to content


Photo

Module want: form builder


  • Please log in to reply
75 replies to this topic

#41 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 07 December 2011 - 04:23 PM

Ah, another one I encountered a while back - do you have the relevant styles in your stylesheet for the error messages? I'm not 100% sure you would see them clearly or at all without the CSS.

#42 Giovanni

Giovanni

    Newbie

  • Members
  • Pip
  • 9 posts
  • 0

Posted 07 December 2011 - 04:41 PM

probably not haha, where can i find them?

#43 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 07 December 2011 - 05:08 PM

They're in the readme file here: https://github.com/r...mplateProcessor

Not saying this will help, but it might.

#44 ryan

ryan

    Hero Member

  • Administrators
  • 5,780 posts
  • 3125

  • LocationAtlanta, GA

Posted 08 December 2011 - 09:22 AM

Also check that the template you are using with this (contact) doesn't have caching turned on. If you need to use caching with the form, you'll want to specify a POST or GET var that must be present to disable the cache (see the cache settings in the template).

#45 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 18 December 2011 - 06:57 AM

I've got a situation where I've got a "request a callback" type form on every page, and a normal contact form on the contact page for a website.

I noticed that if you re-use fields and don't fill the name out on the Contact form, it displays the errors on BOTH forms. I then changed the fields so they each had their own fields, and then when you submit an empty contact form it correctly displays the errors for the contact form, but the other form is replaced by the "Thanks you, your submission has been sent" message.

So... there are some issues with multiple forms on the same page :( Is there any easy way to tweak the code so that it handles multiple forms correctly? I was thinking the easiest might be to pass the template name as a hidden field and also use it as the ID for the form - that way some checking could be made which then correctly processes only the one form (I'm assuming it processing any forms it finds at present?).

#46 ryan

ryan

    Hero Member

  • Administrators
  • 5,780 posts
  • 3125

  • LocationAtlanta, GA

Posted 19 December 2011 - 11:00 AM

The FormTemplateProcessor module was always intended to be a proof of concept and not much more than a starting point for people to customize and build from. At present it's not designed to deal with multiple instances of itself (though could easily be updated to). When it looks to see if a form is submitted, it is checking $input->post->submit. If you've got two forms on the same page, then they are both going to be detect that submit. A better solution would be for it to assign a unique variable (or submit button name) that goes with each form so that one can't be confused for another. When we build a proper form builder/processor, we'll definitely be handling all this stuff in the module. But until then I still think it's better to manage your own forms rather than use this module for it (unless the needs are very simple).

#47 adamkiss

adamkiss

    Master of the universe

  • Moderators
  • 1,078 posts
  • 289

Posted 29 December 2011 - 05:27 AM

Since I haven't gone through this module and its comments, this might be OT:

If you've got two forms on the same page, then they are both going to be detect that submit.


Aren't browser sending only data from form, which has the pressed submit in it? Meaning, if I have form1 with submit1 and form2 with submit2, on submit1 it sends only fields/data from form1 and on submit2 only data from form2?

#48 ryan

ryan

    Hero Member

  • Administrators
  • 5,780 posts
  • 3125

  • LocationAtlanta, GA

Posted 29 December 2011 - 01:28 PM

That's correct, and that would be the simple fix in this case. :) But because this particular module isn't singular (i.e. a new instance is created whenever you load the module) it would have to keep track of how many instances of it are running (via a static variable in the class).

#49 Bill

Bill

    Jr. Member

  • Members
  • PipPip
  • 36 posts
  • 4

Posted 22 February 2012 - 12:28 PM

That's correct, and that would be the simple fix in this case. :) But because this particular module isn't singular (i.e. a new instance is created whenever you load the module) it would have to keep track of how many instances of it are running (via a static variable in the class).


Just saw this and tho i know it's a big deal, my friend and i recently did this on a multiple form page, with potentially the same 'instances' of the form and we incorporated a sorta 'nonce/hash' based on the instance of the 'form' itself. works DANDY too!

it's not a biggie but could be an easy add. (course, i say easy but you get me)

in that way you could also do ajax submits as well.

just sayin'.

#50 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 22 February 2012 - 02:33 PM

I don't suppose you'd be able to share the code would you Bill? No problem if not as I could probably work it out myself next time I need it, but no point everyone doing the same thing either ;)

#51 alchime.net

alchime.net

    Jr. Member

  • Members
  • PipPip
  • 31 posts
  • 0

  • LocationReunion - Island ile de la Reunion

Posted 23 February 2012 - 10:29 AM

What about http://processwire.c...s-the-long-way/
****
???
I install and read the help files for the "form builder module"
but i'm still a bit confused :
* // help file Usage:
*
* 1. In admin, create the fields you want to be part of the form.
OK

* 2. Create a new template and assign your fields to this template.
OK but do i need evey other fields ?- i would say yes..
So that would be a normal template like basic pages + new fields for the form..

* 3. Create another template for your contact form page (if you don't already have one).
That's confusing..
A new template again ? then it's written (if you don't already have one)
How many do I need then !!? ;-)

* 4. Use the example below as a starting point for this contact form page:
(ok thanks Ryan as usual)


Cause i just want an easy way to make contact forms at the end..
with just some different kind of fields depending of the website..

A walkthrought/tutorial would really be great ****
or at least to explicit the number 2 and 3.

Regards,

#52 ryan

ryan

    Hero Member

  • Administrators
  • 5,780 posts
  • 3125

  • LocationAtlanta, GA

Posted 24 February 2012 - 01:14 PM

Alchime, I actually have not tried out that tutorial yet, so need to take a closer look at that. However, attached is a template file (basic-form.php) that is ready to use as a basic contact form with the default site profile. Let me know if this is helpful?

Attached File  basic-form.php.txt   1.98K   242 downloads

Note that you'll have to rename this to basic-form.php, place in /site/templates/. If you want it to email to a specific address (rather than the superuser) than edit the file and enter your email address in at the top where it says to.

#53 alchime.net

alchime.net

    Jr. Member

  • Members
  • PipPip
  • 31 posts
  • 0

  • LocationReunion - Island ile de la Reunion

Posted 26 February 2012 - 01:52 PM

Thanks Ryan it does help ! (and it works nicely enought - i just translate the form in french..)
I'll might try to mix it with the code from the "form builder" because i like the way that email are checked..

Hum.. what about Captcha ? Any thought of that matter ?

Regards,
M.
P.S : Have a really great day !

#54 ryan

ryan

    Hero Member

  • Administrators
  • 5,780 posts
  • 3125

  • LocationAtlanta, GA

Posted 27 February 2012 - 10:53 AM

If you want a really simple captcha that's very effective, add a dummy field near the top of your form like this:

<textarea id='my_message' name='my_message'></textarea>

Then have your CSS stylesheet hide it:

#my_message { display: none; }

Then on your form processing, add this check:

if($input->post->my_message) {
    // message is very likely spam so skip or send it to your spambox
    mail('your.spam.email@company.com', $subject, $message); 
} else {
    // message is good
    mail('your.email@company.com', $subject, $message); 
}

Other captcha solutions would be to add a "What is 5+4?" and verify that they entered 9 (using a method like above). Or add in a captcha service like Recaptcha.

#55 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 27 February 2012 - 03:40 PM

A super-simple one I employed on one of my forums was a Q&A. The question was really simple, such as "What colour is red" and required users to type the word "red". Simply having an extra field throws off a lot of spam bots especially in more common forms where they're used to a standard number of fields, and when they eventually broke through this first tricky type of question on the forum in question I was able to simply change the question to something equally simple.

There was something very satisfying about changing the question just after they'd worked out the last one - I know it's probably all automated but I like to think I've frustrated a human spammer nonetheless ;)

#56 alchime.net

alchime.net

    Jr. Member

  • Members
  • PipPip
  • 31 posts
  • 0

  • LocationReunion - Island ile de la Reunion

Posted 27 February 2012 - 11:43 PM

Thank you both for the Captacha exemple/idea.
I'm always very intersted about the way Ryan do stuff i have to say..
(and i m sure i m not the only one ;-)

Regards,

Alchime

#57 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,530 posts
  • 859

  • LocationVihti, Finland

Posted 28 February 2012 - 01:19 AM

Or add in a captcha service like Recaptcha.


ReCaptcha is pretty damn hard to get right for a half human like me :)

#58 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 28 February 2012 - 03:22 AM

ReCaptcha used to be a bit easier to read for humans - now I usually have to get it to refresh a few times before I can read one as it's got a bit silly lately.

#59 diogo

diogo

    Hero Member

  • Moderators
  • 2,014 posts
  • 1092

  • LocationPorto, Portugal

Posted 28 February 2012 - 04:05 AM

you don't really have to get both words right, you know? One of the words is there because you are helping google to scan thousands of old books.
* thought it would be interesting for those that don't know it ;)

#60 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 28 February 2012 - 03:24 PM

Oh. Oops. :-[




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users