vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.8 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=235)
-   -   New Posting Features - Easy Forms - Create a form or multiple forms without php or html knowledge (https://vborg.vbsupport.ru/showthread.php?t=201097)

arkkhoax 07-08-2009 06:06 AM

Hey! I'm having a small problem with a custom question that defaults to the users age. I'm having problems validating the input when the form is submitted.

For my custom question I have this code (this part works):
PHP Code:

list($month,$day,$year) = explode("-",$vbulletin->userinfo['birthday']);
$year_diff  date("Y") - $year;
$month_diff date("m") - $month;
$day_diff   date("d") - $day;
if (
$month_diff 0$year_diff--;
elseif ((
$month_diff==0) && ($day_diff 0)) $year_diff--;
$realage $year_diff;

$answer '<input type="text" id="q_' $formbit[id] . '" name="' $formbit[id] . '" value="' $realage '" />'

I want the user to be able to change the age I default the question to. I also want to make sure that input is a valid number so I wrote a few lines to do that.

In the "Before Submit" area I have this: (my custom question has an id of 15)
PHP Code:

$q[15] = (int)$q[15]; //make sure we only have a number
if($q[15] < 18$q[15] = 18;
if(
$q[15] > 120$q[15] = 120

Here is where the problem comes in! When the forum is submitted or previewed the text in the age field shows up but my "Before Submit" code does not take effect. So if I were to type "cool" in the age field it shows "cool" in the preview instead of showing 18 as I would expect (type casting 'cool' to an int should return zero, zero is less than 18 so it should be set to 18).

Any help would be great! I'm sure it's just something little I am missing. I know what I am doing may seem a little silly out of context but I want it to work this way. :)

bananalive 07-10-2009 03:30 PM

Quote:

Originally Posted by chet (Post 1844645)
Can this been used as a forum application form, I run a closed forum but would like users to be able to apply to join.

Thanks

Non-registered users can submit forms if you desire. But using it to create new users is not a function

bananalive 07-10-2009 03:32 PM

Quote:

Originally Posted by WickedWeb (Post 1844970)
Im posting this with the disclaimer of many others. I have tried searching this thread but its huge and I've had no luck at the moment so my apology if its been answered.

If it helps any I've Installed* Rated 5 Stars and Nominated as its well deserved for all 3 in my opinion. I can do anything with this.

My problem is this. In the vb form options you can set it for the button to show up in your navbar which I have done. I use a custom template so what I need to do is assign the button a defined height and width along with a class for it to blend nicely with my layout. I have looked in the header and other locations that I can think of looking for anyway to add my desired values but I never see any reference of the button along side the other navbar buttons. Where do I need to be to achieve this?

My sincere thanks

Atm, you have to edit a plugin.

But in v3.7 (available very soon) you can just customise the template form_navbar

bananalive 07-10-2009 03:33 PM

Quote:

Originally Posted by arkkhoax (Post 1844981)
Hey! I'm having a small problem with a custom question that defaults to the users age. I'm having problems validating the input when the form is submitted.

For my custom question I have this code (this part works):
PHP Code:

list($month,$day,$year) = explode("-",$vbulletin->userinfo['birthday']);
$year_diff  date("Y") - $year;
$month_diff date("m") - $month;
$day_diff   date("d") - $day;
if (
$month_diff 0$year_diff--;
elseif ((
$month_diff==0) && ($day_diff 0)) $year_diff--;
$realage $year_diff;

$answer '<input type="text" id="q_' $formbit[id] . '" name="' $formbit[id] . '" value="' $realage '" />'

I want the user to be able to change the age I default the question to. I also want to make sure that input is a valid number so I wrote a few lines to do that.

In the "Before Submit" area I have this: (my custom question has an id of 15)
PHP Code:

$q[15] = (int)$q[15]; //make sure we only have a number
if($q[15] < 18$q[15] = 18;
if(
$q[15] > 120$q[15] = 120

Here is where the problem comes in! When the forum is submitted or previewed the text in the age field shows up but my "Before Submit" code does not take effect. So if I were to type "cool" in the age field it shows "cool" in the preview instead of showing 18 as I would expect (type casting 'cool' to an int should return zero, zero is less than 18 so it should be set to 18).

Any help would be great! I'm sure it's just something little I am missing. I know what I am doing may seem a little silly out of context but I want it to work this way. :)

In Before Submit plugin remove any comments or use instead:
PHP Code:

/* start comment here

end comment */ 

eg.
PHP Code:

$q[15] = (int)$q[15]; /*make sure we only have a number*/
if($q[15] < 18$q[15] = 18;
if(
$q[15] > 120$q[15] = 120


Quantnet 07-10-2009 10:17 PM

Quote:

Originally Posted by bananalive (Post 1844553)
What part did you want to use ajax?

Could we have some fields on the top of the form result table where we can filter the result table by?

If we have like 100 people submit the forms, may be the result can be filtered by one of the choice in a form question.

maybe Ajax can be used here.

Quote:

Originally Posted by bananalive (Post 1844554)
Currently it is not possible for those who cannot edit forms to view form results table. This is something i am working on for v3.7.

Very much looking forward to it.

Quote:

Originally Posted by bananalive (Post 1844549)
1. i might move that into phrase for next version.

2. it's hard coded atm.

3. you'll be missing two javascript files, which are needed for javascript sort table

all are welcome news.

Saviour 07-12-2009 11:30 AM

Just noticed there's an update for this mod...v3.7beta. Are there any release notes as to what this update includes? Also, are there any upgrade instructions?

Thanks, bananalive...for another great mod!

bananalive 07-12-2009 11:41 AM

Quote:

Originally Posted by Saviour (Post 1847403)
Just noticed there's an update for this mod...v3.7beta. Are there any release notes as to what this update includes? Also, are there any upgrade instructions?

Thanks, bananalive...for another great mod!

Version history contains latest additions:

Quote:

v3.7
- Added template hook for form hidden fields
- Added compulsory question * as phrase
- Form Results Table and Form Results Poll moved to templates
- Form Navbar link moved to tempalte
- JavaScript sort results table
- added permissions for Usergroups to view form results (those who can edit forms can also view form results)
Installation Instructions:
  1. Import product file in admincp
  2. upload easyforms.js and easyforms.css to clientscript/

Saviour 07-12-2009 12:02 PM

Thanks, bananalive...

One thing I've noticed, though...

This is displayed on the forms..."Please Note: Questions proceeded by an asterisk (*) are compulsory." Actually, the asterik (*) does not proceed the question, but appears after the question. Also...anyway to change this and make the asterisk (*) red in color?

Quantnet 07-12-2009 01:46 PM

Updated to 3.7 beta and upload the js files. To sort column, just click on the column header name and an arrow down will appear next to the header name.

This is not too obvious to people since it's hard to tell you can sort. Maybe we can add a filter section on top to display only the columns we want in case we have 20+ columns?

joe1989 07-13-2009 12:27 AM

Quote:

Originally Posted by Saviour
Actually, the asterik (*) does not proceed the question, but appears after the question.

"Proceed" means "to come after." Precede means before. The coder is correct; your vocabulary is backwards!


All times are GMT. The time now is 08:46 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03019 seconds
  • Memory Usage 1,782KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_php_printable
  • (9)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (4)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete