Custom Form Mod

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

Previous topic - Next topic

Garou

Sramota, I found the answer to your question about using "0's" in an integer or float box.

In the CustomForm.php you will need to change...
case 'int':
$value = isset($_REQUEST[$field['title']]) ? intval($_REQUEST[$field['title']]) : '';
// If value is empty then set it to the default.
if(($value == '')
&& !$required)
$value = $default;
// Restrict the length of value if necessary.
if(($size != ''))
$value = substr($value, 0, $size);
break;
case 'float':
$value = isset($_REQUEST[$field['title']]) ? floatval($_REQUEST[$field['title']]) : '';
// If value is empty then set it to the default.
if(($value == '')
&& !$required)
$value = $default;
// Restrict the length of the float value if necessary.
if(($size != ''))
$value = rtrim(substr($value, 0, $size), '.');


too...
case 'int':
$value = isset($_REQUEST[$field['title']]) ? intval($_REQUEST[$field['title']]) : '';
// If value is empty then set it to the default.
if(($value === '')
&& !$required)
$value = $default;
// Restrict the length of value if necessary.
if(($size != ''))
$value = substr($value, 0, $size);
break;
case 'float':
$value = isset($_REQUEST[$field['title']]) ? floatval($_REQUEST[$field['title']]) : '';
// If value is empty then set it to the default.
if(($value === '')
&& !$required)
$value = $default;
// Restrict the length of the float value if necessary.
if(($size != ''))
$value = rtrim(substr($value, 0, $size), '.');
break;

You will also need to change in the same file...
// Do we have an invalid value? Is this field required?
if(($required
&& (($value == '') || ($value == '0'))

to
// Do we have an invalid value? Is this field required?
if(($required
&& (($value == '')


In changing

if(($value == '') && !$required)

to

if(($value === '') && !$required)

also causes one more small problem, if the user leaves the field empty "0" will automatically display in the post. Its a trade off as in php language "0" is set as the default for intval and floatval. I read someplace that this is "an incredibly poor design decision" by those that write the php language and  I have to agree.

For everyone using the v1.5 of this mod for the 1.1.x series of SMF take not of the code listed above for floats. You will see that when I messed up my copy/paste when editing the mod for radio boxes and there is no " break;" closing the code for float. This is causing floats not to work properly at all in v1.5 on 1.1.x and will be fixed in v1.6 of the mod.

ɔɔɔɔɔɔuɥoɾ

Oh, one more thing, more of a feature request for this mod.

Would it be too much work to be able to add one more king of field

A field which can choose which board the topic is posted, so if you were having reviews and the competition was Operating systems for example
the boards are named after OS's example, "Windows XP Reviews" and another called "Windows Vista Reviews". The created form would have a drop down menu with the boards you have chosen for custom fields.
That extra feature would make this custom form mod the ultimate in custom forms


SMF 2.0 RC5

   
Webhost to New Webhost file transfer service, PM me - Fast transfers

deciph3red

Not sure what happened (according to my host no changes have been made) but it stopped working.

PHPInfo can be found here:
http://www.clangoat.com/phpinfo.php

I am getting the following error:
An appropriate representation of the requested resource /index.php could not be found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Garou

#803
deciph3red, first check that your ./index.php contains
'form' => array('CustomForm.php', 'CustomForm'),

Have you added any other mods to your site? If not it really sounds to me like your site may have changed your security settings even if they say they haven't. Most likely they may have been supposed to be set for your site but previously were not, so your average tech support wouldn't realize that they have changed. Try to chmod your CustomForm.php and CustomForm.template.php to 755 or 644.

Other then that I don't know what to tell you other then most mods don't break randomly unless something has changed either in the mod's files, SMF files, or server settings many of which you can't control and don't always show up in your php.ini.

johncccccc , I'm not sure what you are asking for there. Are you saying you want the form to post to both boards or that you want the user to be able to choose what board the form posts to?

If its the first, there's a post a couple pages back on how to get your forms to post to multiple boards.

If its the second then its really complicated to do from with in the form and I would suggest creating two separate forms, one posting to each board and letting the users decide which one to use.

ɔɔɔɔɔɔuɥoɾ

Yep, its the second one :)

I knew it would likely be complicated, but it would be a great feature as so save time setting up several forums which will essentially be the exact same thing, besides the board the data is sent to, it would be very convenient.
It was just an idea, but if its possible, I would certainly like it and I'm sure many others will too


SMF 2.0 RC5

   
Webhost to New Webhost file transfer service, PM me - Fast transfers

Garou

#805
Tell you what, Ill add it to my to do list. I like the idea myself but I have no clue about how to make it work or if it really is possible. Ill have to set it aside for now as there are still several other things I do need to get in there first. Since its on the list It wont be forgotten, it might be a while but if it is possible Ill get it in there eventually.

While I'm on the subject I am working on v1.6 now. So far Ive got floats working again in 1.1.x, Ive fixed the problem with using $'s in both Text boxes and Large Text boxes, and Ive added Captcha to both 1.1.x and 2.x. I mentioned in the earlier post with the manual install of captcha for 2.x that I planned on making it optional but in order to make using the mod more secure Ive decided to make it default instead. In both versions of SMF it will always appear for Guests using a form, after that its based on the captcha settings that already exist in SMF. It will be described in greater detail in the help files within the mod.

There's a couple more bug fixes I want to do and Id also like to add a couple more features but I'm planning on releasing v1.6 in the next couple weeks. I should be on vacation from my day job and will have plenty of time to work on it then.

ɔɔɔɔɔɔuɥoɾ

Yea thanks for adding to list.

another option to make forms quickly for different boards, (keeping mod as it is) would be to introduce a "Copy Form" option, which would Copy all settings and fields from that form setup and then you can make the quick changes like board data is sent to and such, then save it as another form. I think that would probably be easier to code up.

I got that idea earlier when I was trying to simply open the database and copy the records 6 at a time, but it wouldn't work as the ID for each field is different regardless of the name been the same, copying them like that would result in duplicate records which is no good.

So if there is some code to add for that feature it may well be easier than adding the other feature


SMF 2.0 RC5

   
Webhost to New Webhost file transfer service, PM me - Fast transfers

Garou

A copy function has been on my to do list for a while now. I even attempted it once but I ran into the same issues you describe. The problem is the numbering system that is used to store the forms. Its probably going to have to take an entire rewrite to make it work or at the very least some weird mathematical formula.

As Nathaniel is working on rewriting the entire thing from scratch I'm hoping he decides to store and number them in an easier to manage format. That way even if he doesn't put a copy function in, I can always add one to it later. :)

ɔɔɔɔɔɔuɥoɾ

Well, I have a somewhat useful idea, maybe the ability to use the same field on several forms would help

the database would store the fields in use on a chosen form as the IDs, but multiple IDs can be used in each column,
Im unsure of MySQL programming, if its possible to set the ID form ( in smf_cf_fields) column to add several form IDs inside, this would let you simply add already existing fields to new form setups


SMF 2.0 RC5

   
Webhost to New Webhost file transfer service, PM me - Fast transfers

deciph3red

Quote from: Garou on October 07, 2009, 07:09:14 AM
deciph3red, first check that your ./index.php contains
'form' => array('CustomForm.php', 'CustomForm'),

Have you added any other mods to your site? If not it really sounds to me like your site may have changed your security settings even if they say they haven't. Most likely they may have been supposed to be set for your site but previously were not, so your average tech support wouldn't realize that they have changed. Try to chmod your CustomForm.php and CustomForm.template.php to 755 or 644.

Other then that I don't know what to tell you other then most mods don't break randomly unless something has changed either in the mod's files, SMF files, or server settings many of which you can't control and don't always show up in your php.ini.

I did speak to my host again, and the guy im dealing with is actually one of the lead techs.  Ive known him for years and he seems to know his stuff.  He has told me they have made no changes in the previous weeks.  I did check for that line in my index.php and it was there.  Also changed permissions, to no avail (added the .htaccess as well).

Im not sure why it would just break.  Heres a list of mods im using:
1.  Favicon  1.2    [ Uninstall ]  [ List Files ]  [ Delete ]
2. Post Prefix 1.1 [ Uninstall ] [ List Files ] [ Delete ]
3. SimplePortal 2.3 [ Uninstall ] [ List Files ] [ Delete ]
4. Anti Spam! 1.1 [ List Files ] [ Delete ]
5. Downloads System 1.2.6 [ Uninstall ] [ List Files ] [ Delete ]
6. Stop Spammer 2.2 [ Uninstall ] [ List Files ] [ Delete ]
7. delete inactive users 1.0.3 [ List Files ] [ Delete ]
8. reCAPTCHA for SMF 0.9.6 [ Uninstall ] [ List Files ] [ Delete ]
9. Treasury 2.36 [ Uninstall ] [ List Files ] [ Delete ]
10. Aeva ~ Auto-Embed Video & Audio 6.9.101 [ Uninstall ] [ List Files ] [ Delete ]
11. Custom Profile Field Mod 3.20 [ Uninstall ] [ List Files ] [ Delete ]
12. Custom Form Mod 1.5 [ Uninstall ] [ List Files ] [ Delete ]


I havent installed anything new. . . so im confused.

Elindris

#810
Hi deciph3red,

  I had the same issue and it was because my host installed mod_security 2.0 on the servers (which do not like ";id=" in the url for some reason... and doesn't accept to be bypassed by the .htaccess code like mod_security 1.x).

To solve the problem, simply change the url to be "...action=form&id=1" instead of "...action=form;id=1"

In order to do so, modify ./Sources/CustomForm.php
Search:
action=form;id=
and replace it with:
action=form&id=

Repeat the operation in ./Themes/Default/CustomForm.template.php

Note: Solution found on SMFHacks.com [nofollow] for Gallery Pro which had the same issue : SMFHacks.com [nofollow] -> Forum -> SMF Gallery Pro -> Support -> Topic: New Gallery Pro Installation Issue (sorry, not allowed to post external links)

Hope this helps!



By the way, LOVE the mod! It's exactly what we've been looking for! And with such a good/active support on the forum, I've also found the answers/workarounds to all my questions/problems. Thanks a lot!

Elindris

Garou

Elindris, Thanks for the help. I seem to remember that fix being posted before but didn't even think about it as its an uncommon problem with the mod. It is something I think Ill have to look into though because mod_security is so widely used. Its also becoming the bane of my personal existence as their last couple releases have made things so restrictive that its not worth using IMHO. Of course unless you own your own server you usually dont have much say in the matter. LOL

deciph3red, try Elindris' fix and let us know if that works.

FireDitto

Something messed up between the change of 1.4 and 1.5, because I now can't access my Features and Options section under Administration... It simply loads as a blank page with the URL in the address bar.

If I go to Installed Packages, and click "Uninstall" it says "An Error Has Occurred!
Unable to find package file!"


If I try to reinstall, I get:

"Apply Mod
This package is already installed, and no upgrade was found!

You should uninstall the old version first to avoid problems, or ask the author to create an upgrade from your old version.

Please remember to always make regular backups of your sources and database before installing mods, especially beta versions."



I am on SMF 1.1.10 and have 50 Installed mods.
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

deciph3red

#813
Quote from: Garou on October 09, 2009, 07:39:32 AM
Elindris, Thanks for the help. I seem to remember that fix being posted before but didn't even think about it as its an uncommon problem with the mod. It is something I think Ill have to look into though because mod_security is so widely used. Its also becoming the bane of my personal existence as their last couple releases have made things so restrictive that its not worth using IMHO. Of course unless you own your own server you usually dont have much say in the matter. LOL

deciph3red, try Elindris' fix and let us know if that works.

Worked great!

Thanks.

On a side note, is there a variable to actually show the forum username?
For example, I want it to show it he subject like this
{Forumname} has applied.

Gmaster83

I install the mod forum CustomFormMod_v1.5_SMF2.x in SMF 2.0 RC1.2.

When I click on any "?" I returned the form:

Fatal error: Cannot create references to/from string offsets nor overloaded objects in /home/xxx/public_html/foro/Sources/Help.php on line 106

I made a form, and when I click on "send" shows me a blank page with:

Numeric request keys are invalid.

Try different configuration without result. Know of any solution?.

Thanks.

Garou

Since this mod doesn't touch ./Sources/Help.php I have to assume you have another mod (I'm going to guess one of the search engine optimization mods) that does and and therefor this mod and most likely other parts of SMF are unable to read the language strings in ./Themes/default/languages/Help.english.php

That or possibly ./Themes/default/languages/Help.english.php is corrupted in some way and the language strings didn't get copied to the file. Compare your file to the changes listed in the package parser for your version.

Gmaster83

#816
I have the Spanish language forum. That error "?" is the least important.

I Uninstall the MOD, and found an error:

./Sources/ManageSettings.php

Proceed with uninstall.

Then I reinstall the MOD:



And when clicking Aply gives me the following error:

Table 'gmaster_foro.cf_forms' doesn't exist
Archivo: /home/gmaster/public_html/foro/Packages/temp/install.php
Línea: 45


This forum is new, and installed a few Mods. I still have not released, wanted to use this form for donations.

Help  :(

(I use google translator  8) )

ɔɔɔɔɔɔuɥoɾ

I think it would be OK to continue installing if you don't use utf8 text in your forum :)


SMF 2.0 RC5

   
Webhost to New Webhost file transfer service, PM me - Fast transfers

Gmaster83

       
I Remove the entries from the DB, change the forum language to English, reinstall the mod and now I can view the help, but when I fill out the form and send it keeps showing me a blank page with:

Numeric keys are invalid request.

>:(

ɔɔɔɔɔɔuɥoɾ

I had that same message about the database, you need to remove the tables from the database and uninstall the mod, then reinstall the mod :)

the address is yoursite.com/index.php?action=form


SMF 2.0 RC5

   
Webhost to New Webhost file transfer service, PM me - Fast transfers

Advertisement: