Hi,
I have multiple forms and some parts of the forms are similar. I was trying to use {{}} in the tpl of form but it seems that the chunks are not parsed by Eform
For example the "eform="Your Name::1:Expected at least two words:#REGEX /^\w+\s\w+/i"" is not parsed by eform.
Is there a way to make eForm load the chunks first then do whatever it needs to do?
Thank You
I think that you would need to load the chunks programatically using an eForm event. Look in your eForm docs for some info in using the events.
eForm docs = assets/snippets/eform/docs
I guess the solution is &eformOnBeforeFormParse
I will access the value of the snippets and just replace them. I was expecting this by default.
I’ll post the solution here If I can make it work
Thank You
solution + example
create a snippet called memberCheck
<?php
function memberCheck(&$fields, &$templates) {
global $modx;
$memberExistingchnk = $modx->getChunk("memberExisting");
$memberNewchnk = $modx->getChunk("memberNew");
$memberYesNochnk = $modx->getChunk("memberYesNo");
$templates[’tpl’] = str_replace("{{memberExisting}}", $memberExistingchnk , $templates[’tpl’]);
$templates[’tpl’] = str_replace("{{memberNew}}", $memberNewchnk , $templates[’tpl’]);
$templates[’tpl’] = str_replace("{{memberYesNo}}", $memberYesNochnk , $templates[’tpl’]);
return true;
}
?>
call eform like this
[!showChunks!]
[!eForm? &formid=`AppTelephoneInternet` &tpl=`eformAppTelephoneInternet` &report=`eFormMemberReport` &eformOnBeforeFormParse=`memberCheck`!]
Have fun
xpix: great example, thanks for posting.
wow. very nice. didnt know you could do that. eform is an amazing piece of work.
should this be a feature of eForm?
It’s not much work. Just detect {{}} get the values inside and replace.
I would gladly update eForm with this.
Thx
Cool! This is eform2chunk chunk2eform snippet! 8)
You can also try this one:
<?php
function memberCheck(&$fields, &$templates) {
global $modx;
$templates['tpl']=$modx->mergeChunkContent($templates['tpl']);
return true;
}
?>
Bruno