News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Custom Form Mod

Started by live627, July 09, 2008, 10:24:44 PM

Previous topic - Next topic

WyckedDreamz

Great idea for a mod! Saves me from having to custom code a TP php form to post to the forums, but I am having an issue. I have my form set up, I can view it just fine, have it set to post to a board, permisions all set, but when I fill in the form, and click submit, the page just refreshes and the required fields text above the submit button turns red, and noting gets posted... am I missing a setting? I don't have anything set to required.





zushiba

Hey, might have been asked but this threads 38 pages long and there's no search this threat feature :(

I've got this installed on my site right now and it's freaking beautiful, it's exactly what we need but since I only allow guests to submit the form when they submit the form To a hidden forum, hidden to everyone but admins it obviously asks them to register. I'd rather not ask them to register as it's not necessary.

Is there any way to get this thing to redirect to another page after the form is submitted?

Garou

For those having problems with required fields...
Quote from: nathan42100 on August 15, 2009, 09:05:29 PM
I fixed it, in CustomForm.php
Find something along the lines of:
// Do a small fix for the last line, if this is a checkbox.
if($field['type'] == 'checkbox'){
$data[$i]['value'] = isset($_REQUEST[$field['title']]) ? $_REQUEST[$field['title']] : false;


Add after:
                    if (($required) && (!$data[$i]['value']))
                    {
                        // Do the 'fail form/field' stuff.
                        $data[$i]['failed'] = true;
                        $fail_submit = true;
                        continue;
                    }


And that $ bug applies to all html with double quotes in it as well, single quotes work fine.

Also something I fixed is the fact that textareas in the template have no size set so they are damn small.

For those looking to redirect to a page other then the board...
Quote from: Garou on May 06, 2009, 10:12:25 PM
This is a quick and dirty fix for people that have forms posting to boards that the user can not access. When a user completes a form this will redirect them to the forum rather then the post that is made.

./Sources/CustomForm.php
Find...
// Redirect this user as well.
redirectexit('board=' . $board . '.0');


Replace With...
// Redirect this user as well.
redirectexit();


Note that this will effect all forms, hopefully in an upcoming version you will be able to chose where a particular form redirects.


I'm working on the next update where the required bug is already fixed and I'm hoping to have something set up so you can choose where to redirect your users after submit.

There's a couple more bugs I'm trying to work out as well as getting another feature or two in there before release. I have a bout 20 things on my "to do list" for the mod and only a few will be in per update. This is mostly due to the amount of time I have (I don't want to leave everyone hanging for a year or so while I try to do it all), also due to my lack of knowledge. I have to be honest and say I just don't know everything yet but I learn a little more each day.  :)

FragaCampos

I'm sorry to ask you this again Garou, but do you know anything about the http:// problem in the form fields? Do you know if this is going to be solved in a near future?

Thanks a lot for keeping this mod alive  ;)

Garou

I'm not sure which http:// problem you mean I have 2 I'm working on and haven't found the answer for either yet.

WyckedDreamz






oistarbwoy

Quote from: pooya on November 19, 2008, 08:41:40 AM
Okay my custom form output isnt being saved, i click save brings me back to the same page with Form Output being blank.

Also how ot make this show in a single topic rather then making different topics ?

i have this exact same problem, everything else works fine. the form posts to board you get a blank message as the output is unable to be saved no matter how many times you click that save button you just come back to the screen again, all info you entered there but with a blank space where all your output layout was written.

i dont get it?

any ideas why this is happening?

Garou

oistarbwoy , there is no single topic option at this time but it is on the "to do list".

As for the form output not saving, The only thing I can think of is that the cf_forms database table wasn't created properly on install for some reason. Uninstall the mod, use phpmyadmin or similar program to manually remove the cf_forms and cf_fields  database tables, then re install the mod.

C4G-TK

Quote from: oistarbwoy on September 19, 2009, 04:23:06 PM
Quote from: pooya on November 19, 2008, 08:41:40 AM
Okay my custom form output isnt being saved, i click save brings me back to the same page with Form Output being blank.



i have this exact same problem, everything else works fine. the form posts to board you get a blank message as the output is unable to be saved no matter how many times you click that save button you just come back to the screen again, all info you entered there but with a blank space where all your output layout was written.

i dont get it?

any ideas why this is happening?

I see that you looked back to November of last year to find someone who had a problem that you had.  I'm not sure if this is the same thing that you are talking about, but do you use the WYSIWYG editor?

If so, I alerted a problem back on page 8 (reply 155) and then again on page 11 (reply 202) and was able to figure out a workaround for the problem on page 11 (reply 203).  It was discussed in full on page 11 (replies 202-205)  Then again, when someone didn't read the previous posts it was reposted on page 15 (reply 295) and on page 26 (reply 510).  Read over the earliest replies and see if this is what you are talking about and to see if the fix I discovered works for you.  It sounds like the same thing.  Hope it helps.

-img removed-

Garou

Wow C4G-TK, great catch, I forgot all about that one. In the back of my mind I thought it was fixed because its not even on my to do list. Looks like Ill have to try and set something up to bypass the WYSIWYG editor settings so it forces the use of the standard editor. Its on the list now. :)

oistarbwoy

#750
Quote from: Garou on September 19, 2009, 08:06:21 PM
oistarbwoy , there is no single topic option at this time but it is on the "to do list".

As for the form output not saving, The only thing I can think of is that the cf_forms database table wasn't created properly on install for some reason. Uninstall the mod, use phpmyadmin or similar program to manually remove the cf_forms and cf_fields  database tables, then re install the mod.

sorry i didnt mean to include the part about the topics i dont care about that at all. its the not being able to save the output thats the problem. clearly this makes the forms not work at all.

also are you sure that there's not a problem in the package? as i also noticed that the title field is there twice in two separate places. i checked the help icon and they are indeed the same feild in oppose to different feilds with similar name.

also quite catastrophically since installing your mod i made the annoying discovery that guests can no longer see anything other then a blank page when they go to index.php or action=forum. all other actions they can see just fine. i tried enabling guest acsess to the form page for guests... but they still cant see my main forum index... they can see the form page though.

please let me know if you have any ideas whats caused the problem so i can fix it in the meantime i'll see what i can figure out myself, but im no coder so i dont fancy my chances :(

i should probably add that uninstalling the mod did not fix my blank screen problem.

Garou

#751
Quote from: oistarbwoy on September 20, 2009, 09:19:00 AM
sorry i didnt mean to include the part about the topics i dont care about that at all. its the not being able to save the output thats the problem. clearly this makes the forms not work at all.
C4G-TK, covered this in his post, essentially you have to turn off the WYSIWYG editor when creating forms. Its a known and almost forgotten about bug that has been added to my to do list. In the meantime just turn it off at least while creating a form.

Quotealso are you sure that there's not a problem in the package? as i also noticed that the title field is there twice in two separate places. i checked the help icon and they are indeed the same feild in oppose to different feilds with similar name.
You are right about the Title Field being in there twice in the 2.x version of the mod. That is not the cause of your problem but will be fixed in the next update.

Quotealso quite catastrophically since installing your mod i made the annoying discovery that guests can no longer see anything other then a blank page when they go to index.php or action=forum. all other actions they can see just fine. i tried enabling guest acsess to the form page for guests... but they still cant see my main forum index... they can see the form page though.

This mod does not alter any of the existing global permissions, it just adds its own to the list. The only permission problem this mod has is that if you do edit the permissions for a group in index.php?action=admin;area=permissions that it will remove all the Custom Form permissions.

In looking at that problem, its caused by the fact that the mod tries to store it's permissions in the permission database but there isn't a function to display them on the permissions page. Therefore when the group permissions are changed it blanks out the ones for the forms. Now that I know whats causing it Ill either have to edit the permissions page to show the CF permissions or move them to the cf_forms database. None the less this isn't the cause of your problem.

If uninstalling the mod didn't fix the problem, I'm sure that the mod isn't what caused it either. My guess is you need to check your index.php?action=admin;area=permissions or perhaps there is a problem with your theme.

Also of note: if the permission to show the form list for a group isn't set in the Custom Form Mod Settings then it should bounce the user back to the Forum Index page. Also if there are no forms set with the permission for that group then the Form List will not show and forms as they cant use them.



oistarbwoy

ok well it never did the bounce back thing it just showed a blank page if you were a guest... so clearly that in itself was not working correctly.

as for it not being this mod, i think thats wishfull thinking seeing as how the ONLY change i made to my working forum was installing the mod and then it stopped working.  its not like i was doing anything else to it.

got to my website everything was fine i could see action=forum. i logged on. i installed the mod set up a form wanted to check that guests could not see the form so logout. they couldnt blank white screen. didnt like the blankness so went back to my main page same for my index.php a blank page unfortunately too. i typed in another action it worked fine. used the header to log in. i switched guest acsess on for forms in admin. logged out. guests could see the forms but not the index.

im not trying to insult your mod but really i dont see how there can be much of a question that the install did something to my forum. i was merely asking for your help, not just chucking blame around.

king kratos

I just noticed in my code that the following portion was missing from the default "function form_template_submit_form()"

    //    Show the "Required Fields" text down the bottom, show it in red if there was a failed submit.
   echo '
               <tr class="windowbg2">
                  <td colspan="3" style="text-align:center;', !empty($context['failed_form_submit']) ? 'color:#FF0000;' : '', '">
                     * ', $txt['CustomForm_required'], '
                  </td>
               </tr>';


I entered the above code just below this:

// Show the 'required' asterix if necessary.
if(!empty($field_data['required']))
echo '
<div ', !empty($field_data['failed']) ? 'style="color:#FF0000;"' : '' ,'> *</div>';

// End the input column and the entire row.
echo '
</td>
</tr>';
}


I'm not sure if this is supposed to not be included in this section, but if it is not included, all fields that are made without specifying a custom template function will not have "* Required Fields" at the bottom of the form.

I have fixed mine, just wanted to let you know that the unedited mod has this error.

Thank you,

Kratos

P.S. I absolutely love this mod. However, some of my forms are submitted to a board and category that is only viewable to admins. This causes an "ugly" error to be displayed when a user submitts a form. Is there any way to submit the form and redirect the user to list of forms or display a less "ugly" message? The message reads as:

Quote
An Error Has Occurred!
The topic or board you are looking for appears to be either missing or off limits to you. 

The board is not missing, it is off limits to unqualified users.

Thank you for any help.

C4G-TK

Quote from: Garou on September 20, 2009, 08:37:44 AM
Wow C4G-TK, great catch, I forgot all about that one. In the back of my mind I thought it was fixed because its not even on my to do list. Looks like Ill have to try and set something up to bypass the WYSIWYG editor settings so it forces the use of the standard editor. Its on the list now. :)

No problem.  I was running another forum at the time, so that's why I have two names.  They both didn't have the same mods, so I made a 2nd name to keep things organized.  The only reason I remembered the fix was because I was determined to figure out why it was happening since it looked like I had installed everything correctly.

-img removed-

Garou

oistarbwoy, when you uninstall a mod it will reverse all the changes it made when it was installed, it returns the modified files to the same way they were before the mod was installed. So if your problem still exists after the mod is uninstalled its not the fault of the mod.

king kratos, I noticed that in the 2.x version of the mod as well when I added my custom template example. As I wasn't sure why it was left out I figured and that LHVWB had his reasons for leaving it out, so I haven't changed it but I did put it in the example. It works with or without that line, I just think it looks better with, Ill probably add it in later anyway. :)

As for your problem with people being redirected to the board when they don't have access to the board I posted this a while back... http://www.simplemachines.org/community/index.php?topic=248871.msg2047400#msg2047400. As for the error message being "ugly", blame SMF that's their standard message for when people try to access a board they don't have access to.  :D I do plan to incorporate something better into the mod within my next update or two though. 

king kratos

Quote from: Garou on September 21, 2009, 08:01:41 AM
As for the error message being "ugly", blame SMF that's their standard message for when people try to access a board they don't have access to.

By "ugly" I simply mean that users see an error that basically says that there is a possibility that their form did not get posted. LOL. Kind of like when Windows throws up random errors and never elaborates on them......

Kratos

Sramota

I'd love to see the Form Fields section be changed into a a menu where you change the data right on that page instead of having to press the "Edit" button.
Also a "Copy" button for them,
having a good 30+ fields with the difference of one number in each just makes it a royal pain to work with as it is..

Garou

For the record, oistarbwoy's problem has been fixed and apparently there is some sort of conflict with Simple Portals permissions and CF's Its been added to the bug list but I have a feeling that once the disappearing permissions bug is fix it will fix this as well.

Sramota  A copy function has been talked about before and is on the to do list but so are several other things so no promises on when it will get added.

As for having all the fields on one page, that's probably not going to happen. It would take a major rework of the mod and I can honestly see it causing more issues then it solves, for most admins and the mod itself.

deciph3red

#759
Question.

It may have been asked in this forum, but i cannot find it for the life of me.

Is there a way to use if-then statements in the actual form itself?

Lets say the custom form is setup like this.  2 Dropdown (selection) boxes labeled like below:
{gamename} = AA2, AA3, CS:S
{laddername} = TWL , CAL

For example. . . the user filling out the form is going to select AA2 for the game, and we are only on TWL for the ladder, so CAL should not be an option.  Is it possible to only have it display TWL for the laddername selection box if they select a game that we compete only on TWL with and vice versa?

Not sure if im explaining it correctly, but having a dropdown box that will only display things that are enabled by selecting a specific option in the dropdown box before it. . .

Also, is it possible to make it create an event in the calendar?

Advertisement: