Hello,
In my feedback form I want to offer the possibility to determine the topic which can be either the particular document where the feedback link was activated, or the website as a whole. I tried to implement that but gave up believing that there must be something wrong with the validation mechanism of eForm. But much more likely the error is on my side.
Approach I:
Using a placeholder to be filled by the
eFormOnBeforeFormMerge callback function
<div class="form-radio-input" style="[+topicNoDisplay+]">
<label for="topic">Concerning</div>
<div id="topic"><input type="radio" name="topic" value="[+ref+]" checked="checked" eform="Topic::1:"/> the page »[+reftitle+]«<br />
<input type="radio" name="topic" value="-1" /> <em>{{SiteName}}</em> in general</p>
</div></div>
That is, it appears to work when you use an event, e.g.:
function onBeforeFormMerge (&$fields) {
global $modx;
$ref = $_REQUEST['ref'];
if ($ref) {
$pi = $modx->getPageInfo($ref);
$fields['ref'] = $ref;
$fields['reftitle'] = $pi['pagetitle'];
}
else $fields['topicNoDisplay'] = 'display:none;';
return true;
}
The placeholders [+ref+] and [+reftitle+] appear properly populated then in the resulting html code. But filling out the form, the validation fails at the topic field. The debug infos of eForm reveal the value from [+ref+] as forgotten again:
'Topic' Failed using rule: #LIST ,-1, (input=32)
'Publication okay?' passed using rule: #LIST 1, (input=1)
'formid' passed using rule: #VALUE feedback, (input=feedback)
Approach II:
It gets even weirder ...
I learned just that snippet calls can be integrated in the eform chunk only with cached notation ([[...]]; [!...!] is left unparsed). So I created a snippet
Get with the content
<?php return $_REQUEST[$param]; ?>
and called it in the chunk:
...<input type="radio" name="topic" value="[[Get? ¶m=`ref`]]" ...
This way I got rid of the placeholder value which seems to interfer with the validation. The snippet call is interpreted as expected.
What says the validation?
'Topic' Failed using rule: #LIST 32,-1, (input=32)
'Publication okay?' passed using rule: #LIST 1, (input=1)
'formid' passed using rule: #VALUE feedback, (input=feedback)
Seems like it refuses the input value although it has been included in the #LIST. So why, where is the problem?
Your help is greatly appreciated,
thank you,
-- agilero.