Dec 04, 2008, 12:55 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Read what MODx Developers say: MODx Dev. Blogs
Pages: 1 ... 7 8 [9] 10 11 ... 23   Go Down
  Print  
Author Topic: [Snippet] eForm - The Electronic form Snippet  (Read 94438 times)
0 Members and 1 Guest are viewing this topic.
zi
MODx Special Forces /
Administrator
*
Posts: 3,014


May Peace Be On You


WWW
« Reply #120 on: Jul 09, 2006, 04:19 PM »

Bumping this thread with my old question:
(Ryan also repeated the question: http://modxcms.com/forums/index.php/topic,2122.msg38863.html#msg38863 )

Anybody here knows why vericode field is self populating when using eForm parser by TobyL ?

regards.

zi
Logged

“Internet Explorer’s CSS rendering: WYSIWTF”. — someone genius
--------------------------------------------------
garryn
Coding Team
*
Posts: 1,181



WWW
« Reply #121 on: Jul 09, 2006, 06:10 PM »

Quote from: Zi
Anybody here knows why vericode field is self populating when using eForm parser by TobyL ?
Yes I do ... Smiley I've only just installed the eForm snippet but I think I've found the problem.

I've had a quick look over the eFormParser.inc.php and noticed in the buildTagPlaceholder() function, the switch ... case statement is missing all-important break statements at the end of each case. Now, this affects the way in which the switch ... case statement functions and how, in this case, the input fields are handled.

I've modified the buildTagPlaceholder() function below to include the statements where I expect them to be (which fixes the problem of the vericode being inserted in the field) but I'm not sure if this affects the intended behaviour of the function as a whole.
Code:
function buildTagPlaceholder($tag,$attributes,$name){
$type = stripTagQuotes($attributes["type"]);
$quotedValue = $attributes['value'];
$val = stripTagQuotes($quotedValue);

foreach ($attributes as $k => $v)
$t .= ($k!='value' && $k!='checked' && $k!='selected')?" $k=$v":"";
switch($tag){
case "select":
return "<$tag$t>"; //only the start tag mind you
                        break;
case "option":
return "<$tag$t value=".$quotedValue."[+$name:$val+]/>";
                        break;
case "input":
switch($type){
case 'radio':
                                        break;
case 'checkbox':
return "<input$t value=".$quotedValue."[+$name:$val+]/>";
                                        break;
case 'text':
                                        break;
case 'password':
return "<input$t value=\"[+$name+]\"/>";
                                        break;
default: //leave as is - no placeholder
return "<input$t value=".$quotedValue."/>";
                                        break;
 
}
case "textarea": //placeholder needs to be added in calling code
return "<$tag$t>";
                        break;
  default:
return "<input$t value=\"[+$name+]\"/>";
                        break;

} // switch
return ""; //if we've arrived here we're in trouble
}
Can somebody who perhaps has some better examples to play around with test the modification to make sure it works okay ....

Anyway, hope that helps,
Garry
Logged

rthrash
Foundation
*
Posts: 9,575



WWW
« Reply #122 on: Jul 09, 2006, 07:53 PM »

While we're on the subject of fixing eForm oddities, how can we take an email address and name entered in the form and make it into the sender address/name... When trying to do it in a call like the following it fails:

The call:
Code:
[!eForm? &formid=`TellAFriend` &sendirect=`1` &to=`[+email+]` &ccsender=`1` &tpl=`TellAFriend` &report=`TellAFriend-report` &subject=`[+fromname+] wants you to see this site` &from=`[+from+]` &fromname=`[+fromname+]`!]

The template part:
Code:
<form name="tell" id="tell" method="post" action="[~[*id*]~]"/>
  <input type="hidden" name="formid" value="TellAFriend"/>
  <input type="hidden" name="email" value="[+email+]"/>
  <fieldset>
  <h3>The Message</h3>
  <label for="fromname">Your Name:
  <input type="text" name="fromname" id="fromname" size="20" value="[+fromname+]" eform="Your name:String:1" />
  </label>
  <label for="from">Your Email:
  <input type="text" name="from" id="from" size="20" value="[+from+]" eform="Your email address:Email:1" />
  </label>

The resulting email header:
Code:
From:   [+from+]@vertexworks.com
Subject: Ryan Thrash wants you to see this site

Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
garryn
Coding Team
*
Posts: 1,181



WWW
« Reply #123 on: Jul 09, 2006, 08:43 PM »

Okay, scrub my last post Cheesy

I've had a better look at the parser now and I can see what it's doing now. I think that there needs to be an additional option included somewhere whether to output the input field with the placeholder included as the value or whether just to output with the original value.

Perhaps, specified as part of the eform attribute? Just an idea ...
Logged

TobyL
Moderator
*
Posts: 812



« Reply #124 on: Jul 09, 2006, 10:33 PM »

First of all sorry to you all for not following the forums as I should. I've got a bad shoulder and at the moment it makes computer work rather tedious.

Quote
I've had a quick look over the eFormParser.inc.php and noticed in the buildTagPlaceholder() function, the switch ... case statement is missing all-important break statements at the end of each case. Now, this affects the way in which the switch ... case statement functions and how, in this case, the input fields are handled.

Perhaps I'm a sloppy and lazy programmer leaving the break statements out but they are not really needed here.  Since each case statement ends with a return the break statement is never executed anyway.

Quote
Anybody here knows why vericode field is self populating when using eForm parser by TobyL ?

eFormParseTemplate() inserts placeholders for all input tags. As I hadn't used the vericode myself (and failed to test it) I overlooked this.  The simple soution is to exclude the vericode field from being handled. In  eFormParseTemplate() around line 74 insert the extra line as shown below. that should do the trick.


Code:
<?php

//existing code
$tagAttributes = attr2array($fieldTags[$i]);
//attribute values are stored including quotes
//this avoids problems with embedded quotes
//strip quotes as well as any brackets to get the raw name
$name = str_replace(array("'",'"','[',']'),'',$tagAttributes['name']);
//added line below
//exception for vericode field
if($name=="vericode") continue;

?>

Logged

garryn
Coding Team
*
Posts: 1,181



WWW
« Reply #125 on: Jul 09, 2006, 11:43 PM »

Quote
Perhaps I'm a sloppy and lazy programmer leaving the break statements out but they are not really needed here.  Since each case statement ends with a return the break statement is never executed anyway.
Not at all ... my bad for not initially understanding what the code was doing (too many coffees and late nights for me, lol).

Wish you a speedy recovery with your shoulder Smiley

Quote from: Ryan
While we're on the subject of fixing eForm oddities, how can we take an email address and name entered in the form and make it into the sender address/name...
I tried this out and added in the following lines at line 205 in the eform.inc.php and it appears to do the trick:
Code:
$from = formMerge($from,$fields);
$fromname = formMerge($fromname,$fields);

That will parse the placeholders for the 'from' and 'fromname' parameters passed in the snippet call with the field values posted back by the form.
Logged

rthrash
Foundation
*
Posts: 9,575



WWW
« Reply #126 on: Jul 10, 2006, 09:23 AM »

Two great fixes Toby and Garry... thanks!

When I get a couple more things wrapped up I'll post a hacked  up version and some sample in the first post that includes all the fixes. This needs to be added to the New Repository!
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
xwisdom
Foundation
*
Posts: 1,732



« Reply #127 on: Jul 10, 2006, 04:04 PM »

I believe $report should be replaced by $autotext.
Encountered this tiny bug in multiple versions, don't know whether it still exists in the latest version or not.

PS.
eForm is a great snippet, keep up the good work!

Many thanks. You're correct on this one.
Logged

xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.
rthrash
Foundation
*
Posts: 9,575



WWW
« Reply #128 on: Jul 10, 2006, 04:16 PM »

Which instance or instances of $report need to be replaced in that code section... I am assuming both:

Code:
# load autotext template
if (strlen($autotext)<50) {
 if(is_numeric($autotext)) $autotext = ($doc=$modx->getDocument($autotext)) ? $doc['content']:"Document id '$autotext' not found.";
 else if($autotext) $report = ($chunk=$modx->getChunk($autotext)) ? $chunk:"Chunk '$report' not found.";
}

Quote
I believe $report should be replaced by $autotext.
Encountered this tiny bug in multiple versions, don't know whether it still exists in the latest version or not.
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
DesignationAlpha
Jr. Member
*
Posts: 4



WWW
« Reply #129 on: Jul 10, 2006, 05:13 PM »

Code:
# load autotext template
if (strlen($autotext)<50) {
if(is_numeric($autotext)) $autotext = ($doc=$etomite->getDocument($autotext)) ? $doc['content']:"Document id '$autotext' not found.";
else if($autotext) $report = ($chunk=$etomite->getChunk($autotext)) ? $chunk:"Chunk '$report' not found."; // <== OVER HERE
}

# load report template
$report_tpl_id = $report;
if (strlen($report)<50) {
if(is_numeric($report)) $report = ($doc=$etomite->getDocument($report)) ? $doc['content']:"Document id '$report' not found.";
else if($report) $report = ($chunk=$etomite->getChunk($report)) ? $chunk:"Chunk '$report' not found.";
}
To avoid any misunderstanding: both instances of $report at the marked line ("over here") will have to be replaced by $autotext. A few lines below this line a similar statement is used. Perhaps a copy/paste bug? Roll Eyes No shame, I fall for this one every time Wink
Logged
rthrash
Foundation
*
Posts: 9,575



WWW
« Reply #130 on: Jul 10, 2006, 05:27 PM »

Thanks for the clarification, DestinationAlpha.

One thing I noticed in implementing an eForm recently is the need to control the output better of error messages and success messages. This would be a great candidate for another chunk.

The other pressing nice-to-have would be the ability to have multiple To addresses with individual messages instead of using JS to build the to address list.

In the interim, as soon as I nail down one last oddity with sending to multiple senders via javascript, I'll put together a patch release and sample with all the stuff you'll need to nail down a Tell-a-Friend form.
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
TobyL
Moderator
*
Posts: 812



« Reply #131 on: Jul 10, 2006, 07:18 PM »

@Raymond This is going way back to http://modxcms.com/forums/index.php/topic,2122.msg37105.html#msg37105

Quote
I'm thinking of single like rules. Maybe something like:

eform="Field Description:Datatype:Requirements"
Where Requirements can be:
0 - for NOT required (default)
1 - for Required
#RANGE:1-N
#LIST:a,b,c,N
etc...

example

eform="Age:number:#RANGE:18-50"

What do you think?

My fault for not following the forums Embarrassed I've already implemented some @binding stuff but I have to agree with you it might not be such a good idea afterall. Your suggestion looks better.  I'll look into changing over the code I've done but as I'm not able to be very active at the moment should I send/post the validation functions I've written? (considering that an eForm update/patch is on the way)  It also includes some changes to the error messages.
Logged

Dimmy
Testers
*
Posts: 1,824


Я не говорю по-русски 私は日本語を話さない


WWW
« Reply #132 on: Jul 11, 2006, 02:07 AM »

is there a posibility to make a form in eform user indentified (I do not know a good word for this but i explain my point)
a way to let the reciever know who the webuser was that sended the message. I am planning to make a ordering form for a chinese restaurand where you can order online bu only when you are a registerd user (that way false orders ar history) would be great if we could personolise the form atleast at the receiphers site.

Dimmy
Logged

"They say if you play a Microsoft CD backwards, you hear satanic messages. That's nothing, because if you play it forwards, it installs Windows."
Nederlands beste portal voor pda en mobiel internet
rthrash
Foundation
*
Posts: 9,575



WWW
« Reply #133 on: Jul 11, 2006, 08:34 AM »

Only make the form visible to registered users. Then use Personalize or Membercheck to customize the output.
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
xwisdom
Foundation
*
Posts: 1,732



« Reply #134 on: Jul 11, 2006, 08:39 AM »

To get the user's login name inside your form you need create a Snippet or TV that returns the user's name and then store that value inside a hidden field:

<input type="hidden" name="username" value="[[GetLoginName]]" />
« Last Edit: Jul 11, 2006, 09:01 AM by xwisdom » Logged

xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.
Pages: 1 ... 7 8 [9] 10 11 ... 23   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!