Another fun challenge today... I’m trying to set the default values of some fields in an eform to a logged in webuser’s profile details. I can’t get it to work at all. For example, I tried to set it to the logged in users name via PHx:
value="[+phx:userinfo=`username`+]"
and by using [[GetUserName]]:
$pid = $modx->getLoginUserID(); $data = $modx->getUserInfo($pid); return $data['fullname'];
with the following field:
value="[[GetUserName]]"
Ideas ... or is it just a wonky bug I’ve run into?
[[GetUserName]] [!eForm sessionVars=`defaultEmail` ... !]
<input type="text" name="email" value ="[+defaultEmail+]" />
Just a wild guess is that MODx tags IN form tags will not get parsed because eForm parses the template before MODx can get to it.
<input type="text" name="email" value="[[getUserName]]" />
« MODx Parse Error » MODx encountered the following error while attempting to parse the requested resource: « PHP Parse Error » PHP error debug Error: Invalid argument supplied for foreach() Error type/ Nr.: Warning - 2 File: /www/assets/snippets/eform/eform.inc.php Line: 651 Line 651 source: foreach ($attributes as $k => $v) Parser timing MySQL: 0.0015 s (6 Requests) PHP: 0.0847 s Total: 0.0862 s
[!eForm? &formid=`contact` &to=`[email protected]` &tpl=`contactform` &report=`contactreport` &thankyou=`contactthanks` &subject=`Website feedback`!]
<div class="form-row"> <div class="field-label"><label for="email">Email Address</label>:</div> <div class="field-label"><input name="email" id="email" class="required validate-email" onBlur="this.value=this.value.replace( /\s+/g, '' );" size="30" maxlength="50" title="Please enter your email address." value="[+email+]" eform=":email:1" /></div> </div>
Once I get this eForm using the function for db-Insertion (+noemail), I’ll be set!! Great work!
I thought it was fixed. Now my form will come up, but when I submit I get this error:
« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
PHP error debug
Error: Invalid argument supplied for foreach()
Error type/ Nr.: Warning - 2
File: /var/www/WEVmodX/modx-0.9.2.1/assets/snippets/eform/eform.inc.php
Line: 651
Line 651 source: foreach ($attributes as $k => $v)
Parser timing
MySQL: 0.0129 s s (15 Requests)
PHP: 0.1351 s s
Total: 0.1480 s s
... <option value=Greenland (Pituffik)"">Greenland (Pituffik)</option> ...
This discussion is closed to further replies. Keep calm and carry on.