Make eForm replace chunks and snippets
on 09-Dec-2009 | Comments ( 8 ) Tags: Evolution
eForm 1.4.6.6 and lower will not replace chunks and snippets found in the eForm template.
The solution is really simple and makes use of the modx APIs and eForm's eformOnBeforeFormParse event.
The eFrom template
Create the eform template testCSTpl and paste the following:
<form method="post" action="[~[*id*]~]">
<input type="hidden" name="formid" value="testCS" />
[[snippetInEFORM]]
{{chunkInEFORM}}
<input type="submit" name="submit" value="Submit">
</form>
The parsing snippet
Create the replaceChunksAndSnippets snippet
<?php
function replaceChunksAndSnippets(&$fields, &$templates) {
global $modx;
$templates['tpl']=$modx->mergeChunkContent($templates['tpl']);
$templates['tpl']=$modx->evalSnippets($templates['tpl']);
return true;
}
?>
The snippet/eForm calls
[!replaceChunksAndSnippets!][!eForm? &formid=`testCS` &tpl=`testCSTpl` &eformOnBeforeFormParse=`replaceChunksAndSnippets` ... !]
Use the above solution with the one here and all your eForm resources can be kept in files.
Limitations:
- You can only use "cached" snippets: [[]]
- The eForm tags in your chunks and snippets will NOT be parsed by eForm.
Write a comment
Posts: 6
Reply #8 on : Thu January 14, 2010, 14:34:11
Posts: 2
Reply #7 on : Thu January 14, 2010, 15:37:04
Posts: 6
Reply #6 on : Fri February 19, 2010, 08:25:04
Posts: 6
Reply #5 on : Fri February 19, 2010, 08:28:41
Posts: 6
Reply #4 on : Fri February 19, 2010, 08:30:40
Posts: 6
Reply #3 on : Fri February 19, 2010, 08:40:23
Posts: 2
Reply #2 on : Fri February 19, 2010, 12:32:53
Posts: 6
Reply #1 on : Tue June 01, 2010, 16:34:31