| Post |
|
therenderghost - Guest
1:17 pm - August 20, 2008
|
| |
|
[desc]: I'm using cforms to create a job application form which includes a drop down select box to enable the applicant to select the job post they are applying for. I'm using categorised wordpress posts to list the job positions. I would like, if possible, the drop down list to automatically reflect the currently published post titles in a particular category so my client doesn't have to go into the Cforms back end to change things. Does anybody know if and how this could be done?
|
|
|
Oliver
- Admin
6:00 pm - August 20, 2008
posts 3562 |
| |
|
First, I recommend upgrading to 8.6.2.
Secondly, this can be done via dynamic forms (see online HELP for examples).
|
|
|
The Renderghost - Guest
8:50 pm - August 25, 2008
|
| |
|
Thanks for the reply,
Have updated to cforms 8.7, wordpress 2.6.1
I've had a look through the help files and the dynamic form creation examples.
Sorry to say I'm still confused.
I used the 'more advanced example (file access)' as a starting point and changed the month drop down to job titles, but still can't figure out how to pull post titles into that list.
Do I replace 'months.txt' with a .php file calling the current posts titles, or is there a simpler way.
The form is embeded in each post so can I cut out the dropdown list and just insert the post title automatically in a text only field.
Sorry for my ignorance but I'm quite new to this level of coding and am obviously slightly out of my depth.
All help is most appreciated.
|
|
|
Oliver
- Admin
9:48 pm - August 25, 2008
posts 3562 |
| |
|
Sorry I can't explain in detail what needs to be done, I'm super swamped. The examples are just examples, no need to follow them 100%.
The key for each is, that an array needs to be built including all the input fields and their configuration (which is the same config string as if you were to set them up in GUI).
If you need to setup a drop down list, then you first need to access all the relevant data (e.g. list of posts etc.) assemble those into a string and "feed" it into the cforms field array. If it's just the current post's title, even simpler.
|
|
|
therenderghost - Guest
8:32 pm - August 26, 2008
|
| |
|
Thanks again Oliver.
I realise you are busy so I'm not expecting you to solve this but I'm hoping someone else might be able to if they stumble across this thread.
I've got a form kinda built and am still struggling to get the post titles fed to the selectbox.
Here's what I've got so far:
<?php
$fields['label'][0] ='Your Name|Your Name'; $fields['type'][0] ='textfield'; $fields['isreq'][0] ='1'; $fields['isemail'][0]='0'; $fields['isclear'][0]='1';
$fields['label'][1] ='Email'; $fields['type'][1] ='textfield'; $fields['isreq'][1] ='1'; $fields['isemail'][1]='1';
$fields['label'][2] ='Website|http://'; $fields['type'][2] ='textfield'; $fields['isreq'][2] ='0'; $fields['isemail'][2] ='0';
$fields['label'][3]='Job Title|Please pick a job title|-';
// I need to pull a list of post titles in category '7' and pass them to the drop down select box // I don't know how to code this bit // 1) create an string of post titles using query_posts or WP-query??? // 2) feed it to the field array ??
$fields['type'][3] ='selectbox'; $fields['isreq'][3] ='1'; $fields['isemail'][3]='0';
$fields['label'][4] ='CV upload'; $fields['type'][4] ='upload'; $fields['isreq'][4] ='0';
$fields['label'][5] ='Demo upload'; $fields['type'][5] ='upload'; $fields['isreq'][5] ='0';
$fields['label'][6] ='Answer this question'; $fields['type'][6] ='verification'; $fields['isreq'][6] ='1';
insert_custom_cform($fields,8); //Call form #8 with new fields
?>
Cheers
|
|
|
Oliver
- Admin
10:03 pm - August 26, 2008
posts 3562 |
| |
|
well done so far. for field #3:
$fields['label'][3]='Job Title|Please pick a job title|-';
try adding:
global $post;
$options = '';
$myposts = get_posts('category=7');
foreach($myposts as $post)
$options .= '#'.get_the_title($post->ID);
$fields['label'][3] .= $options;
|
|
|
The Renderghost - Guest
1:52 am - August 27, 2008
|
| |
|
As it was it didn't work as there were a couple of curly brackets missing from the 'foreach' statement (I eventually worked out!). Once I got those in it worked.
What a relief!! Thank You!
One slight issue is the drop down lists first line is blank and can be selected.
Any ideas on how I can eliminate this?
The code as it currently stands
<?php
$fields['label'][0] ='Your Name|Your Name';
$fields['type'][0] ='textfield';
$fields['isreq'][0] ='1';
$fields['isemail'][0]='0';
$fields['isclear'][0]='1';
$fields['label'][1] ='Email';
$fields['type'][1] ='textfield';
$fields['isreq'][1] ='1';
$fields['isemail'][1]='1';
$fields['label'][2] ='Website|http://';
$fields['type'][2] ='textfield';
$fields['isreq'][2] ='0';
$fields['isemail'][2] ='0';
$fields['label'][3]='Job applying for#Please select one|-#';
global $post;
$options = '';
$myposts = get_posts('category=7');
foreach($myposts as $post) {
$options .= '#'.get_the_title($post->ID);
}
$fields['label'][3] .= $options;
$fields['type'][3] ='selectbox';
$fields['isreq'][3] ='1';
$fields['isemail'][3]='0';
$fields['label'][4] ='Your Message';
$fields['type'][4] ='textfield';
$fields['isreq'][4] ='0';
$fields['isemail'][4]='0';
$fields['isclear'][4]='1';
$fields['label'][5] ='CV upload';
$fields['type'][5] ='upload';
$fields['isreq'][5] ='0';
$fields['label'][6] ='Demo upload';
$fields['type'][6] ='upload';
$fields['isreq'][6] ='0';
$fields['label'][7] ='Answer this question';
$fields['type'][7] ='verification';
$fields['isreq'][7] ='1';
insert_custom_cform($fields,''); //Call form
|
|
|
Oliver
- Admin
6:29 am - August 27, 2008
posts 3562 |
| |
|
It looks like you're doing the right thing.
the '-' in combination with setting the field to 'required' should do the trick.
can I see the form in action?
|
|
|
The Renderghost - Guest
4:03 pm - August 27, 2008
|
| |
|
http://osh1.com/?page_id=8
Also...
Verification is missing Q&A.
What do I need to do there?
|
|
|
Oliver
- Admin
7:22 am - August 28, 2008
posts 3562 |
| |
|
Your mandatory drop down seems to work just fine now (you might want to remove that double '#' to avoid the empty line).
Not sure why Q&A is missing in your form, because I took your above code 1:1 and it works 100%.
Can you double check for spelling mistakes or anything like that...
|
|
|
The Renderghost - Guest
3:16 pm - August 28, 2008
|
| |
|
Not sure what I did but it's working now.
Got rid of the second # which solved the blank line and re-uploaded it and it's all good.
Thanks again for all your help and making such a flexible plugin in the first place.
|
|
|
The Renderghost - Guest
3:37 pm - September 4, 2008
|
| |
|
Oliver
There's one thing that's not quite right with this drop down.
The form only pulls in the last 5 posts for the specified category.
Why would this be and how do i get around this?
Any ideas?
|
|
|
Oliver
- Admin
10:22 pm - September 4, 2008
posts 3562 |
| |
|
Perhaps one needs to tell get_posts()to not limit the number of posts to retrieve, like WP does for the front page (where it only shows a certain number of posts).
|
|
|
therenderghost - Guest
10:28 pm - September 4, 2008
|
| |
|
Solved it by replacing
$myposts = get_posts('category=7');
with
$myposts = query_posts('cat=7');
|
|
|
therenderghost - Guest
7:40 pm - September 5, 2008
|
| |
|
Oliver
I'm going crazy trying to work out what's not right with this dynamic form.
The visitor verification Q&A isn't working.
When submitbutton is clicked it returns with 'Please fill in all the required fields' highlighting the Q&A as the offending field.
If I use a non-dynamic form the Q&A works fine.
Do I need to add some extra rules into my dynamic forms code?
Or do I need to put it in its own field set? If so how to I do this?
Regards
<?php $fields['label'][0] ='Your Name|Your Name'; $fields['type'][0] ='textfield'; $fields['isreq'][0] ='1'; $fields['isemail'][0]='0'; $fields['isclear'][0]='1'; $fields['label'][1] ='Email'; $fields['type'][1] ='textfield'; $fields['isreq'][1] ='1'; $fields['isemail'][1]='1'; $fields['label'][2] ='Website|http://'; $fields['type'][2] ='textfield'; $fields['isreq'][2] ='0'; $fields['isemail'][2] ='0'; $fields['label'][3]='Job Title applying for#Please select one|-'; global $post; $options = ''; $myposts = query_posts('cat=7'); foreach($myposts as $post) { $options .= '#'.get_the_title($post->ID); } $fields['label'][3] .= $options; $fields['type'][3] ='selectbox'; $fields['isreq'][3] ='1'; $fields['isemail'][3]='0'; $fields['label'][4] ='Your Message'; $fields['type'][4] ='textarea'; $fields['isreq'][4] ='0'; $fields['isemail'][4]='0'; $fields['isclear'][4]='1'; $fields['label'][5] ='CV upload'; $fields['type'][5] ='upload'; $fields['isreq'][5] ='0'; $fields['label'][6] ='Demo upload'; $fields['type'][6] ='upload'; $fields['isreq'][6] ='0'; $fields['label'][7] ='SPAM PREVENTION: Please respond to the following question with a one word answer.'; $fields['type'][7] ='textonly'; $fields['label'][8] ='Spam Prevention'; $fields['type'][8] ='verification'; $fields['isreq'][8] ='1'; insert_custom_cform($fields,''); //Call form ?>
|
|
|
therenderghost - Guest
8:12 pm - September 5, 2008
|
| |
|
latest atempt.....
removed second upload field.
added fieldset start and end around verification.
still not working.
have I coded fieldsets wrong?
<?php $fields['label'][0] ='Your Name|Your Name'; $fields['type'][0] ='textfield'; $fields['isreq'][0] ='1'; $fields['isemail'][0]='0'; $fields['isclear'][0]='1'; $fields['label'][1] ='Email'; $fields['type'][1] ='textfield'; $fields['isreq'][1] ='1'; $fields['isemail'][1]='1'; $fields['label'][2] ='Website|http://'; $fields['type'][2] ='textfield'; $fields['isreq'][2] ='0'; $fields['isemail'][2] ='0'; $fields['label'][3]='Job Title applying for#Please select one|-'; global $post; $options = ''; $myposts = query_posts('cat=7'); foreach($myposts as $post) { $options .= '#'.get_the_title($post->ID); } $fields['label'][3] .= $options; $fields['type'][3] ='selectbox'; $fields['isreq'][3] ='1'; $fields['isemail'][3]='0'; $fields['label'][4] ='Your Message'; $fields['type'][4] ='textarea'; $fields['isreq'][4] ='0'; $fields['isemail'][4]='0'; $fields['isclear'][4]='1'; $fields['label'][5] ='Please up load your cv, showreel, and/or demos here. Upload .zip if you have multiple files. Max size ?Mb.'; $fields['type'][5] ='textonly'; $fields['label'][6] ='Upload'; $fields['type'][6] ='upload'; $fields['isreq'][6] ='0'; $fields['label'][7] ='SPAM PREVENTION: Please respond to the following question with a one word answer.'; $fields['type'][7] ='textonly'; $fields['fieldsetstart'][8] ='spamoff'; $fields['label'][8] ='Spam Prevention'; $fields['type'][8] ='verification'; $fields['isreq'][8] ='1'; $fields['fieldsetend'][8] ='spamoff'; insert_custom_cform($fields,''); //Call form ?>
|
|
|
Oliver
- Admin
8:26 pm - September 5, 2008
posts 3562 |
| |
|
not sure what is happening, since your code works just fine on my test system, including Q&A.
How did you configure your Q&A settings under "global-settings" ?
Q=A and a new line for each entry?
|
|
|
therenderghost - Guest
8:50 pm - September 5, 2008
|
| |
|
The colour of grass is?=green The colour of snow is?=white The opposite of up is?=down
|
|
|
Oliver
- Admin
8:57 pm - September 5, 2008
posts 3562 |
| |
|
|