Posts: 16
Threads: 8
Joined: Jul 2009
Reputation:
0
Sep 23rd, 2009, 5:09 PM
(This post was last modified: Sep 23rd, 2009, 8:28 PM by invectus.)
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.
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hey Invectus,
Sure, no problem.
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
Posts: 16
Threads: 8
Joined: Jul 2009
Reputation:
0
(Sep 23rd, 2009, 6:26 PM)Ben Wrote: Hey Invectus,
Sure, no problem.
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
Posts: 16
Threads: 8
Joined: Jul 2009
Reputation:
0
(Sep 23rd, 2009, 6:38 PM)invectus Wrote: (Sep 23rd, 2009, 6:26 PM)Ben Wrote: Hey Invectus,
Sure, no problem.
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
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
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. 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
|