cforms II User Forum

Registration is currently disabled.
Guest

FAQs

Login form protected by Login LockDown.


Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

    

Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
dynamic form using post information - anybody done it?
July 6, 2007
6:01 pm
RIch Schmidt
Guest

I just came across cforms, and it looks like it'll do just what I'm looking for!  However, being a total novice when it comes to PHP & MySQL, if someone else has already done this, and would be willing to share their code, it would certainly save me some time…

 

I'm upgrading a website for a community group in which some people will be entering volunteer work projects as posts in certain categories (based on which city they're in).  I'm hoping to use cforms then as the signup form for people who want to serve, with a dropdown list that grabs those post titles so they can select which project they want to volunteer for.

 

Make sense?

 

Reading the docs here, it looks like it can certainly be done…  I'm just wondering if anybody already has.  :)  If not, I'll share what I come up with once I'm done with it…

 

Thanks! 

 

PS – The website is http://www.sharefestpc.org , if anyone's interested… 

July 6, 2007
8:01 pm
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

Rich, have you looked at the examples in the HELP section? Start with the simple one, once you have it up and running tailor the code to meet your requirements.

To get a list of post titles you may have either get into MySQL  and write the respective SQL queries from scratch or find a plugin that helps to do that. 

July 6, 2007
11:21 pm
RIch Schmidt
Guest

Yep, I've looked at the examples, which is what makes me think it's doable.  I'm hoping that standard WP function calls will get me where I need to go… but I haven't started digging into it yet.  Today's been too busy!   :)

July 8, 2007
10:03 am
Rich Schmidt
Guest

OK, I've done it, using the get_posts function and get_the_title function inside the Loop (which should already be there, if you're on a Page or in a Post).  The relevant section looks like this:

 

            $fields['label'][4] = 'Sign me up for:#Choose one|-';
            $posts = get_posts('numberposts=50&category=4&order=ASC&orderby=post_title');
            foreach ($posts as $post) :
            $fields['label'][4] .= '#'.get_the_title();
            endforeach;
            $fields['type'][4]   ='selectbox';

You can see it in action at:

http://www.sharefestpc.org/valparaiso/sign-me-up-valparaiso/

The list of post titles it's grabbing can be seen on this page:

http://www.sharefestpc.org/valparaiso/ 

It's not really integrated into the site yet.  Most of it is still last year's site (with last year's method).

 

The problem I have now is that when I hit the submit button, I get taken to what seems to be a random post (except that it's the same one every time), no email gets sent, and nothing gets put into the database.  It's set to give a success message, not redirect, and all the email config information seems to be filled out correctly.  It's on WP 2.0.2, Firefox 2.0.0.4 on the Mac.  I don't have time to dig into that one right now…

 

 

July 8, 2007
10:39 am
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

I see you're making good progress, great!

Here is what happens (I think):

Dynamic forms only work in non Ajax mode, hence cforms needs to submit/post the data & reload the page for validation & further processing.

Since you've tinkered with the get_the_title etc.  WP function call, it looks like it changed the current get_permalink to the last item in your post list. Cforms uses get_permalink to determine the form action and consequently, when reloading, loads the wrong page and nothing happens – of course.

Two options I see:

  1. Adjust the way you gather the post data, so it doesn't influence get_permalink()
  2. Try to "hardcode" the form action via the cforms admin UI: look for Redirect form data to… and set it to
    http://www.sharefestpc.org/valparaiso/sign-me-up-valparaiso/
July 27, 2007
5:31 am
Rich Schmidt
Guest

Like I said in my last comment (if it made it thru moderation), the latest version of the plugin fixed my redirect problem.  If you want to see it in action, I'm using it at http://www.sharefestpc.org .  I'm using it for the "Contact Us" page, but the fun stuff is on the "Sign Me Up" pages.  The link above doesn't get you there anymore… now it's http://www.sharefestpc.org/sign-me-up/ and then click on one of the city names to see that city's form.

Thanks for a GREAT plugin!  The only thing that would make it better would be the ability to do a CSV export of just one of the forms (without having to click on every individual form entry one at a time).  I'm going to have forms for 3-5 cities, plus the Contact Us form, plus another one, for a total of 5-7 forms.  I'll never need to export all of them together, because they'll all be different.  But right now I don't see any easy way to export just one of the forms' tracked results.

But that's about the only thing I can think of!  Thanks again!

July 27, 2007
5:34 am
Rich Schmidt
Guest

You know what, maybe that "last comment" I referred to was just in my head.  :)

August 4, 2007
2:12 pm
Oliver
Munich, Germany
Admin
Forum Posts: 6400
Member Since:
March 6, 2005
Offline

Rich Schmidt said:

Like I said in my last comment (if it made it thru moderation), the latest version of the plugin fixed my redirect problem.  If you want to see it in action, I'm using it at http://www.sharefestpc.org .  I'm using it for the "Contact Us" page, but the fun stuff is on the "Sign Me Up" pages.  The link above doesn't get you there anymore… now it's http://www.sharefestpc.org/sign-me-up/ and then click on one of the city names to see that city's form.

Thanks for a GREAT plugin!  The only thing that would make it better would be the ability to do a CSV export of just one of the forms (without having to click on every individual form entry one at a time).  I'm going to have forms for 3-5 cities, plus the Contact Us form, plus another one, for a total of 5-7 forms.  I'll never need to export all of them together, because they'll all be different.  But right now I don't see any easy way to export just one of the forms' tracked results.

But that's about the only thing I can think of!  Thanks again!


good point, I'll put that on the v5.4 todo list.

Forum Timezone: Europe/Berlin

Most Users Ever Online: 959

Currently Online:
28 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

tracedef: 43

mores: 21

Gyrus: 20

frozenwaste: 18

asuffredini: 15

photoworks: 14

Member Stats:

Guest Posters: 3732

Members: 1463

Moderators: 3

Admins: 2

Forum Stats:

Groups: 1

Forums: 4

Topics: 5332

Posts: 18695

Newest Members: juredujmovic, dreamkeeper, rajattyagi, wrokaa, lukass

Moderators: Paul (421), cnymike (8), sonika (95)

Administrators: Oliver (6400), Nicky (3)