I’ve run into an unexpected issue with my usual pre-populating event function: It doesn’t seem to work for textarea fields. If I replace the field name below with one that refers to a regular input field (e.g., name, email), this code works as expected. But textareas don’t seem to have their values pre-parsed using this method.
function preFormParse(&$fields){
global $modx;
$evt=&$modx->event;
$validFormId=($evt->params['formid']==$_POST['formid']);
$isPostBack=($validFormId && count($_POST)>0);
if (!$isPostBack) { // Check for NOT postback, since we only want to prepopulate an empty form
$fields['message']=<<<EOF
letter text here...
EOF;
}
else { // the form has been posted, so pre-process any data here
// code to preformat phone numbers, etc.
}
return true;
}
I think the next thing I’ll try is adding a placeholder to the template and using the &$templates reference to preset that. But this seemed as if it might indicate a need to revisit the logic of pre-parsing field values. Or am I just confused?