Topic: eForm placeholder not working  (Read 982 times)

Pages: [1]   Go Down

#1: 21-Oct-2008, 07:39 AM


Taff
Posts: 465

Lovin' ModX

WWW
What am I doing wrong...

I've used it before without any trouble but with the

Code:
&subject=`[+name+] filled out the website form`


where name looks like

Code:
<input id="name" class="formInput" maxlength="32" name="name" size="30" type="text" value="" />

in the contact form. Now according to the new docs it should now be &subject=`[.name.] filled out the website form` but that isn't working either.

Using 0.9.6.3-RC1MODX and 1.4.4.5 EFORm...Can anyone offer a pointer please?

Cheers,
Taff
Me: www.adrianlawley.com ::

Just started on: www.softselect.de, a Business Software Selection and Consultancy Company. English Version is available as of today, hoping for a relaunch asap...to get rid of those pesky frames.

Just finished (more or less) http://www.trendlux.de

#2: 3-Nov-2008, 11:31 AM


Taff
Posts: 465

Lovin' ModX

WWW
Could it be that I'm using php 4.4.4?

Cheers,
Taff
Me: www.adrianlawley.com ::

Just started on: www.softselect.de, a Business Software Selection and Consultancy Company. English Version is available as of today, hoping for a relaunch asap...to get rid of those pesky frames.

Just finished (more or less) http://www.trendlux.de

#3: 16-Nov-2008, 11:08 AM


rossco
Posts: 932

WWW
I'm having issues with the value="" setting when using eform as well...  When I put value="test" it's showing up as value="".  How do you put default information in the inputs with eform?

#4: 16-Nov-2008, 11:29 AM


mrhaw
Posts: 1,929

modx == freedom

WWW
http://modxcms.com/forums/index.php?topic=7521.msg53034#msg53034
« Last Edit: 16-Nov-2008, 01:55 PM by mrhaw »
My playground: http://4up2date.info | Twitter: mrhaw
---> Check out: ReadSpeaker webReader Plugin | Support/Comments Thread

--=[ MR. HAW ]=--

#5: 16-Nov-2008, 03:00 PM


rossco
Posts: 932

WWW
Hmmm what I'm trying to do is create an eform that allows registered users email the creator of a particular document.  My idea was to send the form to [*createdby*] email address and have it display which user sent the form.  I'm not sure if this is possible with eform. 

#6: 16-Nov-2008, 09:54 PM

Moderator

TobyL
Posts: 1,024

I'm having issues with the value="" setting when using eform as well...  When I put value="test" it's showing up as value="".  How do you put default information in the inputs with eform?

eForm is currently not retaining default values for text input fields. By making the following change to eform.inc.php (version 1.4.4.5) you can change this behaviour:
Find this block of code around line 817
Code:
<?php //do not copy this line!
   
}elseif($fieldType=='checkbox' || $fieldType=='radio'){
      
$formats[$name][4]= $_lang['ef_failed_default'];
      
$formats[$name][5] .= isset($formats[$name][5])?",":"#LIST ";
      
//convert embedded comma's in values!
      
$formats[$name][5] .= str_replace(',','&#38;#44;',stripTagQuotes($tagAttributes['value']));
      
//store the id as well
      
$formats[$name][6] .= ( isset($formats[$name][6])?",":"").stripTagQuotes($tagAttributes['id']);
   } 
//<-- INSERT NEW CODE HERE (replacing bracket)

and insert this:
Code:

<?php //do not copy this line!
 
} else { //plain old text input field
      //retain default value set in form template
      
$fields[$name] = stripTagQuotes($tagAttributes['value']);
   }
Hmmm what I'm trying to do is create an eform that allows registered users email the creator of a particular document.  My idea was to send the form to [*createdby*] email address and have it display which user sent the form.  I'm not sure if this is possible with eform. 
[*createdby*] will give you the user id, so you would have to retrieve the corresponding email address from the users settings first.
Basically what I understand is that you want the TO email field to be the document creator and the FROM email field to be the currently logged in user (and perhaps the subject to something like the page_id or title)

You could do this with an eForm event function where you retrieve the values from modx and add them to the $fields array -and- have some extra placeholders in your snippet call:

For instance you could this function in the eFOrmOnBeforeMailSent event:
Code:
<?php //do not copy this line!
/**
* eForm event function to retrieve logged in user and page creator details
* Use following placeholders in eForm:
* [+login_email+] & [+login_name+] for the logged in user
* [+creator_email+] & [+creator_name+] for the page creator
* [+page_title+] for page title
*/
function beforeMailSentFunction(&$fields){
   global 
$modx;
   
   if( ! 
$login_info $modx->userLoggedIn() ){
      
$fields['validationmessage'] = "You are not logged in. Please log in before trying again.";
      return 
false;
   } 
   
//get logged in user details:
   
$user_info= = ($login_info['usertype']=='manager') ? 
      
$modx->getUserInfo($login_info['id']) : $modx->getWebUserInfo($login_info['id']);
   
//add to fields array
   
$fields['login_email'] =  $user_info['email']; 
   
$fields['login_name'] = $user_info['fullname'];
   
//get document title;
   
$fields['page_title'] = $modx->documentObject['pagetitle'];
   
//get document creator details
   
$cr_info $modx->getUserInfo($modx->documentObject['createdby']);
   
$fields['creator_email'] = $cr_info['email'];
   
$fields['creator_name'] = $cr_info['fullname'];
   
   return 
true;
   
}

and use a snippet call like this:
Code:
[!eForm? &subject=`User comment on [+page_title+]` &to=`[+creator_email+]` &from=`[+login_email+]` &eformOnBeforeMailSent=`beforeMailSentFunction` !]

I'm assuming you know how to get event functions to work.. otherwise see examples in this forum
Check if you have PHx enabled. If you do the above will not work out of the box. See pixelchutes PHx workaround elsewhere (do a fourm search as I can't remember...)

 

#7: 20-Nov-2008, 02:08 PM


rossco
Posts: 932

WWW
I'm trying to get the to and from parameters to work still.  I have tried and just don't seem to get it working.  I tried editing the eform file but it's not working.
Pages: [1]   Go Up
0 Members and 1 Guest are viewing this topic.