The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
SOLVED: Ignore default field values if no data entered - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8)
+--- Forum: Modules (https://forums.formtools.org/forumdisplay.php?fid=16)
+--- Thread: SOLVED: Ignore default field values if no data entered (/showthread.php?tid=300)



SOLVED: Ignore default field values if no data entered - invectus - Sep 23rd, 2009

Hi there,

BTW This is a brilliant module, especially if you know what you're doing; I hope this can help me.

I'm using Jquery to change the default value of a field on focus.
If no data is entered into that field, the default value is displayed.

I'm using this technique as a way to enrich the user's experience while filling the form instead of the old fashion <label> tag.

The problem is that any field that wasn't filled returns it's default value to the database and I know you know how unfunny this is.

I was hoping to tell the form to ignore any field that contained certain values.

I would appreciate any help.


RE: Ignore default field values if no data entered - Ben - Sep 23rd, 2009

Hey Invectus,

Sure, no problem. Smile

There's a couple of ways you could do it.
1. JS approach: On form submit, right before the content is actually submitted, you could empty the fields
2. Use this module and add rules like so:

PHP Code:
if ($_POST["my_field"] == "default value"
  
$_POST["my_field"] = "";
if (
$_POST["my_field2"] == "another default value"
  
$_POST["my_field2"] = ""

That's pretty much it! You would, of course, have to set up a pre-parser rule for your particular form and add the PHP above as the content. But there's no reason why it wouldn't work!

Hope this helps -

Ben


RE: Ignore default field values if no data entered - invectus - Sep 23rd, 2009

(Sep 23rd, 2009, 6:26 PM)Ben Wrote: Hey Invectus,

Sure, no problem. Smile

There's a couple of ways you could do it.
1. JS approach: On form submit, right before the content is actually submitted, you could empty the fields
2. Use this module and add rules like so:

PHP Code:
if ($_POST["my_field"] == "default value"
  
$_POST["my_field"] = "";
if (
$_POST["my_field2"] == "another default value"
  
$_POST["my_field2"] = ""

That's pretty much it! You would, of course, have to set up a pre-parser rule for your particular form and add the PHP above as the content. But there's no reason why it wouldn't work!

Hope this helps -

Ben

Ben, as alway's,

you're very helpful. Let me give it a try and let you know what happened.

Cheers,
Invectus


RE: Ignore default field values if no data entered - invectus - Sep 23rd, 2009

(Sep 23rd, 2009, 6:38 PM)invectus Wrote:
(Sep 23rd, 2009, 6:26 PM)Ben Wrote: Hey Invectus,

Sure, no problem. Smile

There's a couple of ways you could do it.
1. JS approach: On form submit, right before the content is actually submitted, you could empty the fields
2. Use this module and add rules like so:

PHP Code:
if ($_POST["my_field"] == "default value"
  
$_POST["my_field"] = "";
if (
$_POST["my_field2"] == "another default value"
  
$_POST["my_field2"] = ""

That's pretty much it! You would, of course, have to set up a pre-parser rule for your particular form and add the PHP above as the content. But there's no reason why it wouldn't work!

Hope this helps -

Ben

Ben, as alway's,

you're very helpful. Let me give it a try and let you know what happened.

Cheers,
Invectus

OMG Ben,

This thing is nuts! I don't know if you realize how powerful FT2 is.
If sold, it would cost lots. No kidding.

It's working like a charm.

I will be back with a few more questions and if you have some spare time, maybe you can use some of my annoying questions to detail how powerful FT is.

Much appreciated bud,

Cheers,

Invectus


RE: SOLVED: Ignore default field values if no data entered - Ben - Sep 26th, 2009

Hey Invectus.

You just wait...! I'm working on a "Hooks Manager" module this weekend that lets you add custom HTML onto any webpage and attach any other code to any functionality in the UI. It's totally cool. Smile The Submission Pre-Parser is basically just offering a very small subset of the Hooks Manager functionality.

Of course it'll be completely bewildering to most folks, so I suspect I'll be spending an awfully long time documentating how it's used and examples... *sigh*. Still, it's really cool.

- Ben