Recent Topics

1 Sep 14, 2008 21:08    

My b2evolution Version: Not Entered

So I use b2evo on a couple of websites. On one of them I have to make up forms every now and then. Complicated forms, meaning many MANY fields that need to be filled in based on exactly what the deal is.

Specifically I use it to allow registration for an annual event. We provide a t-shirt with registration, so I have to ask for size. We also provide a meal so I have to ask what meal you want. I have to cover cost, and my boss in this case adds the paypal charge to the registration price if you use paypal. So if your total cost to register is 85 USD and you choose to pay via paypal then your total cost is 85 plus 3 percent of 85.

So would it not be cool if we had a plugin that would allow the admin to easily generate new forms? I always base everything off the message form. Seems like a good place to start given that I will eventually be sending a message about the new response. The thing I'm looking for is a plugin method to create the appropriate bits. Currently I hack the skins and skins/skinname and htsrv folders. IF a plugin was to ask me to fill out details then provide me with the files I needed to hack and upload that would be fantastic! Notice the exclamation mark there after the word fantastic? See how fantastic it would be?

I want a plugin that facilitates a thing I must do from time to time. I suppose eventually I could craft a plugin, but OMG it is taking me FOREVER to craft a plugin that embeds videos in a better fashion than the stock 'videoplug' plugin does. Perhaps someone who is much smarter than I understands my request and empathizes with me and knows how to make such a thing and doesn't mind crafting a plugin that tells me to save this file as whatever and upload it to whereever?

Uncle Bob says hi!

2 Sep 14, 2008 23:07

Hm, I think it wouldn't be too hard to write a plugin which allows the admin to create forms in the backoffice and then displays them with a SkinTag() (or embed it into a post? That's the way the WP plugin does it). The plugin then would save the form data in the database or send an email to the admin.
Did I understand you? :)

3 Sep 14, 2008 23:25


Save all the submitted data in the database, and send the info to the admin. But so much more as well. Like, send the submitted info to a list of persons who need the info. And of course validate the info against a set of definable criteria before recording it in the database. And making a summary of databased info available to the people on the list of who gets the new data in their email.

4 Sep 14, 2008 23:35

EdB wrote:

Save all the submitted data in the database, and send the info to the admin.

OK, that's easy.

EdB wrote:

Like, send the submitted info to a list of persons who need the info.

A list of blog members (that would make it easier to show them the summary you mentioned)?

EdB wrote:

And of course validate the info against a set of definable criteria before recording it in the database.

Would it be enough to check if the data is for example a date or a telephone number and to implement things like marking a field as required?

5 Sep 15, 2008 00:32

So here is what I've done in the past. The information submitted is basically easily validated. "Is the field filled in?" "Does the email field look like an email address?" Simple stuff like that. Almost every other field has been a radio select option, meaning I can set a default and they can change to only one other option. Obviously a checkbox select feature could do the same, but with radio buttons I can display all the options on the page for them with semi-long selections.

Assuming all the content passes validation I then send it to a list of email addresses that need it. Not all of those are associated with login accounts! They are simply email addresses of those who have a need to know the submission content. Oh and there is always a field for general text. Basically think of the message form with more requirements before submitting the message.

The list of who gets the email is an easy hack, and no it is not dependent on a user_ID. One of the common recipients for my common application can barely check email, so I sure can't expect him to log in anywhere. Basically all I do is fake the $send_to (or something like that) portion of the file in htsrv that sends the email to message recipient.

For accessing a summary of submitted info yeah one must be logged in. To handle that what I do is use "if is_logged_in()" in the skin to show different links in the sidebar. If someone is logged in they can see links for various summaries of the submitted info. For one particular player I also offer a link to "mark as paid" any given submission. That would be the club treasurer. People out there use the form to register for an annual event. Part of what they do is say how they will pay - check or paypal. The club treasurer eventually gets the money and marks the person as "paid". That feature gets handled after "if is_logged_in()". Basically those who can see that page might see "mark as paid" if their login ID matches a short list of those who might get the money.

Kinda complicated, but I would so much rather see a method to build a form in the back office than to have to hack it up each time I need it. The installation this matters to me the most in is still living on 1.10.3 because I have/had to wait until the annual event completed. Soon I will have a narrow window to fully upgrade all the hackage there so I can bring that intallation to 2.4.2, but I will still be hacking up this form each year for both the annual events I have to handle.

So yeah a back office method would be way better than hacking last year's hack in last year's version :)

6 Sep 15, 2008 00:34

Again: if a plugin simply provides me with the files I need to add to /skins/ and /htsrv/ that'd be way better than what I do right now. It doesn't have to take care of every tiny detail though. Just enough to build a functional form that can distribute emails to a list and give a summary to a limited audience of logged in persons.

7 Sep 15, 2008 13:21

Well, OK, I think I'll look at it next weekend. It's monday here in Germany atm and only on weekends I've enough time for coding (school...). :)

8 Sep 15, 2008 13:34

Would it be good enough if it made a "post" for each form submission with the "mark as paid" == edit post and replace no with yes ?


Scrap that, I'm guessing the answer's "no" :p .... hmmmm ... *puts thinking cap on*

9 Sep 15, 2008 14:21

Yeah scrap it is right.

But actually the whole idea is pretty cool - even if my specific needs go to an illogical extreme. "A method to make a new form with a variable number of form fields that may or may not require some sort of validation".

So like the first thing would be a database that stores the name of a form. Then you need to add fields to the form. Each field can be maybe a text box or a select or a series of radio buttons, and obviously needs a default value. If validation is required then the admin states the validation when creating the field. Eventually a "full" form is created - all info stored in a database of course. At some point a link to the form is created, so that'd be something to put in a widget. Like maybe just a sidebar link in a free HTML widget, or maybe it's own widget (per form).

If it takes something like "here is the page for this folder and there is the page for that folder" that would, to me, be fine because generally this plugin wouldn't be aimed at the total dummy user. But wow imagine if the form got created on the fly every time. Slick eh?

So upon creation of a new form with fields a new table would be created that can track information added to the form. When you get into tracking the info you probably get into very situation-specific stuff. For example my club gives you a tee shirt for registering, so one of the things I have to count up is how many of each size is needed. Total tee shirts and a size distribution eh? And how many have actually been paid for of course ... and who paid.

Another thing I do is make the email that goes to all the players (the club president, treasurer, the guy who cooks the dinners, the guy who makes the tee shirts, the web master, the guy who is coordinating launches and the people who have donated something and are watching raffle ticket sales) seem like it is coming FROM the person who filled out the form. That way they can reply of course.

Damn I ramble.

Wouldn't it be cool if we could easily tweak the message form process to make a form dynamically?

10 Sep 15, 2008 14:44

As it happens, I've got a form to email class lying around that already does a fair bit of what you want

1) ( fairly ) easily defined fields ( I'll post a sample form page below )
2) radio ability, now that your request made me find 2 bugs in my code and fix them :p
3) sends to multiple email accounts
4) emails sent from the person who filled them in
5) validation, and custom messages
6) required fields, and custom messages
7) custom html per filed ( probably won't need this )
8) built-in ( basic ) anti-spam

What it doesn't have ( at the moment )
1) custom email message, it just sends a list of all fields and their values .... it's the geek in me ;)
2) ability to slap data in a database ... real simple to add though ;)
3) ability to pull information from a database .. shouldn't be rocket science to add
4) ability to summarise ... but I never even considered that as an option when I coded it :roll:

Sample page :

//ini_set( 'display_errors', 'on' );
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" xml:lang="en-UK" lang="en-UK">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
/* Forms */
margin:1em 0 0 0;

.field_error li,
.error li{
margin:0 0 0 11em;

margin:0 10px;

form .input label{
margin:0 1em 0 0;

form .notes{

form .input{
margin:0 0 1em 0;

form .input input{

form .input textarea{

form .inpButtons{
<!-- start of form -->
define( 'YABBA', 'hello world' );

require_once dirname(__FILE__).'/../am_email.class.php';

$Email = & new am_email();

		// define all the fields to be used by the form
		$Email->DefineField( array(
												'name' => 'client_name',
												'nice_name' => 'Name',
												'type' => 'text',
												'size' => 40,
												'required_error' => 'Please tell us your name',
												'html' => '<div class="input"><label for="%name%">Your name : </label>%field%</div>',
											) );
		$Email->DefineField( array(
												'name' => 'domain',
												'nice_name' => 'Domain',
												'type' => 'hidden',
												'allow_urls' => 1,
											) );

		$Email->DefineField( array(
												'name' => 'ip_addy',
												'nice_name' => 'IP',
												'type' => 'hidden',
												'default' => $_SERVER['REMOTE_ADDR'],
												'lock_field' => true,
											) );

		$Email->DefineField( array(
												'name' => 'ref',
												'nice_name' => 'Referrer',
												'type' => 'hidden',
												'allow_urls' => 1,
											) );

		$Email->DefineField( array(
												'name' => 'client_email',
												'nice_name' => 'Email',
												'type' => 'text',
												'size' => 40,
												'required_error' => 'It\'s a little bit difficult to reply without your email ;)',
												'validation' => 'email',
												'validation_error' => 'Please enter a valid email address',
												'html' => '<div class="input email"><label for="%name%">Email address : </label>%field%<span class="notes">Your email address will only be used to reply to your enquiry.</span></div>',
											) );

		$Email->DefineField( array(
												'name' => 'other_info',
												'nice_name' => 'Additional Notes',
												'type' => 'textarea',
												'html' => '<div class="input email"><label for="%name%">Other information : </label>%field%<span class="notes">Please tell us any other information you feel is relevant</span></div>',
												'required_error' => 'It helps if you tell us what the problem is',
												'allow_urls' => 1,
											) );

		$Email->DefineField( array(
												'name' => 'test',
												'nice_name' => 'Radio test',
												'type' => 'radio',
												'html' => '<div class="input email">Testing : %field%</div>',
												'values' => array( 'Yes', 'No' ),
											) );

echo '<div id="enquire">
<form method="post" action="#enquire">
<div><input type="hidden" name="action" value="do" />';
$Email->AutoSend( array( '', '', ''  ), 'Email subject line', 'client_email' );
echo '<fieldset>
	<legend>Contact sombody</legend>';
$Email->DisplayField( 'client_name' );
$Email->DisplayField( 'client_email' );
$Email->DisplayField( 'other_info' );
$Email->DisplayField( 'test' );
echo '<div class="inpButtons"><input type="submit" value="Submit Report" name="submit"/></div>
<p>Please note : we advise that you don't spam this form or you're liable to be banned forever ;)</p>
<!-- end of form -->

I'll PM you a link to the output of that form ( not ready for the domain to become to *public knowledge* atm ) and I'll add your email addy to the list of senders ( dev list email addy ) so you can see what you get

Sorry for the multi-liner sir ;)


11 Sep 15, 2008 18:52

Hi. What about use the same scheme that we use to generate the admin pages for plugins to generate these forms?

Form is loading...

Advanced CMS – This forum is powered by b2evolution CMS, a complete engine for your website.