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 <?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(',','&#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:
<?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:
<?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:
[!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...)